题解 | #未完成试卷数大于1的有效用户#

未完成试卷数大于1的有效用户

https://www.nowcoder.com/practice/46cb7a33f7204f3ba7f6536d2fc04286

select
    uid,
    sum(if (submit_time is null, 1, 0)) as incomplete_cnt,
    count(submit_time) as complete_cnt,
    group_concat(
        distinct concat_ws (':', date (start_time), tag)
        order by
            start_time separator ';'
    ) as detail
from
    examination_info ei
    join exam_record er on ei.exam_id = er.exam_id
where
    uid in (
        select distinct
            uid
        from
            exam_record
        where
            year (start_time) = 2021
        group by
            uid
        having
            count(submit_time) >= 1
            and sum(if (submit_time is null, 1, 0)) between 2 and 4
    )
    and year (start_time) = 2021
group by
    uid
order by
    incomplete_cnt desc

这编辑器格式化代码在group_concat后面加了个空格就报错,找了半天才发现去了就能运行

向找出2021年完成试卷作答数至少为1且未完成数大于1小于5的用户,然后从中算出数据,注意外层也要限制时间

全部评论
无语了 找了半小时了 感恩
点赞 回复 分享
发布于 2023-09-15 10:16 广东

相关推荐

CrazyBucket:我今天下午也做梦在招聘会上面试一家小厂,给自己气笑了
点赞 评论 收藏
分享
1 收藏 评论
分享
牛客网
牛客企业服务