题解 | #试卷发布当天作答人数和平均分#
试卷发布当天作答人数和平均分
https://www.nowcoder.com/practice/5b58e89556dc4153a79d8cf8c08ba499
select er.exam_id as exam_id,count(distinct er.uid) as uv,round(avg(score),1) as avg_score from user_info as uf right join exam_record as er on uf.uid=er.uid left join examination_info as ei on er.exam_id=ei.exam_id where ei.tag='SQL' and level>'5' and date_format(submit_time,'yyyy-mm-dd')=date_format(release_time,"yyyy-mm-dd") group by er.exam_id order by uv desc,avg_score;
连表(拿到题目要做的事情),条件查询(题目要求),分组(不分组会报错,因为字段用了聚合函数),排序(题目要求),秒了