题解 | #满足条件的用户的试卷完成数和题目练习数#

满足条件的用户的试卷完成数和题目练习数

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

select
table1.uid
,exam_cnt
,question_cnt
from
(
    select
    uid
    ,count(exam_id) exam_cnt
    from 
    (
        select
        *
        from exam_record
        where substring(submit_time,1,4) = '2021'
    ) t7
    where uid in
    (
        select
        t1.uid uid
        from exam_record t1 left join examination_info t2
        on t1.exam_id = t2.exam_id
        left join user_info t3
        on t1.uid = t3.uid
        where tag = 'SQL'
        and difficulty = 'hard'
        and level = 7
        and t1.submit_time is not null
        and substring(start_time,1,4) = '2021'
        group by 1
        having avg(t1.score) > 80
    )
    group by 1
) table1

left join

(
    select
    t5.uid
    ,count(question_id) question_cnt
    from user_info t5 left join 
    (
        select
        *
        from practice_record
        where substring(submit_time,1,4) = '2021'
    ) t6
    on t5.uid = t6.uid
    where t5.uid in
    (
        select
        t1.uid uid
        from exam_record t1 left join examination_info t2
        on t1.exam_id = t2.exam_id
        left join user_info t3
        on t1.uid = t3.uid
        where tag = 'SQL'
        and difficulty = 'hard'
        and level = 7
        and t1.submit_time is not null
        and substring(start_time,1,4) = '2021'
        group by 1
        having avg(t1.score) > 80
    )
    group by 1
) table2
on table1.uid = table2.uid
order by exam_cnt,question_cnt desc

全部评论

相关推荐

03-12 15:35
嘉应学院 Python
快说谢谢牛牛精灵:说不定就是下一个寒武纪!
点赞 评论 收藏
分享
UtopianYou...:这个简历排版真的不太行哦,去找免费的或者花点小钱,把排版弄整齐一点吧,看着舒服。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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