题解 | #试卷发布当天作答人数和平均分#

试卷发布当天作答人数和平均分

http://www.nowcoder.com/practice/5b58e89556dc4153a79d8cf8c08ba499

select 
exam_id
,count(distinct uid) as uv
,round(avg(score), 1) as avg_score
from
(select 
er.uid
,ui.level
,er.exam_id
,ei.release_time
,er.start_time
,er.submit_time
,er.score
,ei.tag
from examination_info as ei left join exam_record as er
    on ei.exam_id = er.exam_id
left join user_info as ui
    on er.uid=ui.uid
where ei.tag='SQL' and er.submit_time is not null and er.start_time > ei.release_time
) as t1
where date_format(t1.release_time, "%Y%m%d") = date_format(t1.start_time, "%Y%m%d") 
    and t1.level > 5 
group by exam_id
order by uv desc, avg_score asc
;





全部评论

相关推荐

10-30 23:23
已编辑
中山大学 Web前端
去B座二楼砸水泥地:这无论是个人素质还是专业素质都👇拉满了吧
点赞 评论 收藏
分享
10-31 14:54
已编辑
门头沟学院 算法工程师
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务