题解 | #试卷发布当天作答人数和平均分#
试卷发布当天作答人数和平均分
https://www.nowcoder.com/practice/5b58e89556dc4153a79d8cf8c08ba499
select i.exam_id,count(distinct u.uid) as uv,round(avg(e.score),1) as avg_score from user_info as u right join exam_record as e on u.uid=e.uid right join examination_info as i on e.exam_id =i.exam_id where level>5 and i.tag = 'SQL' and date_format(i.release_time,"%Y-%m-%d")='2021-09-01' group by i.exam_id order by uv desc,avg_score asc
# 思路:
#1,三表进行关联,求出sql的试卷并求出级别为5的相关信息,
# 2,因为要求出当天五级以上的用户作答的人数,所以此时应筛选日期,然后分组,分组依据为考试exam_id,count求出相关的人数(此处要进行去重)
#3,最后是求出其平均分。这里进行了讨巧,发布当天直接根据提示写出的,严格来说这里的当天是发布时间跟开始做答的时间一致
# start_time=release_time