题解 | #试卷发布当天作答人数和平均分#
试卷发布当天作答人数和平均分
http://www.nowcoder.com/practice/5b58e89556dc4153a79d8cf8c08ba499
- SELECT e.exam_id , count(DISTINCT uid ) as uv ,ROUND(avg(score) ,1) AS avg_score
- FROM
- (SELECT uid, ei.exam_id ,submit_time ,score
- FROM examination_info ei LEFT JOIN exam_record er
- ON ei.exam_id = er.exam_id
- WHERE tag = 'SQL' and DATE(submit_time) = DATE(release_time) ) AS e
- WHERE uid IN (SELECT uid FROM user_info WHERE level > 5 )
- GROUP BY e.exam_id
- ORDER BY uv DESC , avg_score