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

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

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

with t1 as (
    select a.uid, a.exam_id, a.score, b.tag
    from exam_record as a
    left join examination_info as b
    on a.exam_id = b.exam_id
),
t2 as (
    select d.uid, d.exam_id, d.score, c.level
    from user_info as c
    right join (
        select uid, exam_id, score
        from t1
        where tag = 'SQL' and score IS NOT NULL
    ) as d
    on c.uid = d.uid
),
t3 as (
    select uid, exam_id, score
    from t2
    where level > 5
)
select exam_id, count(distinct uid) as uv, round(AVG(score), 1) as avg_score
from t3
group by exam_id
order by uv desc, avg_score;

全部评论

相关推荐

09-17 19:25
已编辑
太原理工大学 游戏测试
叁六玖:公司名发我,我要这个HR带我打瓦
我的秋招日记
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务