题解 | #月均完成试卷数不小于3的用户爱作答的类别#

月均完成试卷数不小于3的用户爱作答的类别

https://www.nowcoder.com/practice/b1d13efcfa0c4ecea517afbdb9090845?tpId=240&tqId=2183022&ru=/exam/oj&qru=/ta/sql-advanced/question-ranking&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26tab%3DSQL%25E7%25AF%2587%26topicId%3D240

# 题目中的当月理解为2021-09
select
    tag,
    count(uid) as tag_cnt
from exam_record
join examination_info using(exam_id)
where uid in (
    select uid 
    from (
        select 
            uid,
            count(score) as total
        from exam_record
        where date_format(start_time, '%Y-%m') = '2021-09'
        group by uid
    ) t1
    where total >= 3
)
group by tag
order by tag_cnt desc

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务