明确问题:查找出当天每个题单的刷题量
首先计算出当天的每个题单的刷题数量,利用current_date函数把日期定在今天
  • select subject_id,count(subject_id)cnt
  •  from  submission
  • where create_time=current_date
  • group by subject_id
 然后与subject表进行连接,最后提交数量降序,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