题解 | #今天的刷题量(一)#
今天的刷题量(一)
http://www.nowcoder.com/practice/e18f56796ae94c3d885e61c8d57a950e
明确问题:查找出当天每个题单的刷题量
首先计算出当天的每个题单的刷题数量,利用current_date函数把日期定在今天
- select subject_id,count(subject_id)cnt
- from submission
- where create_time=current_date
- group by subject_id
- select b.name,cnt
- from
- (select subject_id,count(subject_id)cnt
- from submission
- where create_time=current_date
- group by subject_id
- ) as a
- join subject as b
- on a.subject_id=b.id
- order by cnt desc ,a.subject_id