题解 | #未完成试卷数大于1的有效用户#题目说的不清不楚的,可以把两段和成一段

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

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

select t1.uid,incomplete_cnt,complete_cnt,detail
from (
       select 
           uid,
           sum(if(submit_time is null,1,0)) as incomplete_cnt,
           sum(if(submit_time is not null,1,0)) as complete_cnt
       from exam_record t1
       join examination_info t2
       on t1.exam_id = t2.exam_id  and year(start_time) = 2021
       where uid in (select distinct uid from exam_record
                       where year(start_time) = 2021
                       group by uid
                       having sum(if(score is not null,1,0)) >= 1 and sum(if(score is null,1,0)) < 5)
       group by uid
       having sum(if(score is null,1,0)) > 1
    ) t1
join (
        select uid,group_concat(d separator ';') as detail
        from (
            select distinct uid,concat_ws(':',date_format(start_time,'%Y-%m-%d'),t2.tag) as d,
                        date_format(start_time,'%Y-%m-%d') as start_time
            from  exam_record t1
            join examination_info t2
            on t1.exam_id = t2.exam_id and year(start_time) = 2021
            order by start_time
            ) t
        group by uid
    )t2
    on t1.uid = t2.uid
order by incomplete_cnt desc

全部评论

相关推荐

自由水:笑死了,敢这么面试不敢让别人说
点赞 评论 收藏
分享
05-19 15:21
已编辑
华南农业大学 Java
白火同学:你才沟通了200,说实话,北上广深杭这里面你连一座城市的互联网公司都没投满呢,更别说还有各种准一线二线城市了。等你沟通突破了三位数,还没结果再考虑转行的事吧。
点赞 评论 收藏
分享
找个工作&nbsp;学历是要卡的&nbsp;要求是高的&nbsp;技能不足是真的&nbsp;实习经验是0的&nbsp;简历无处可写是事实的&nbsp;钱不好赚是真的&nbsp;想躺平又不敢躺&nbsp;也不甘心躺&nbsp;怕自己的灵感和才华被掩埋甚至从未被自己发现&nbsp;又质疑自己是否真正有才华
码农索隆:你现在啊,你心里都明白咋回事,但是你没办法改变现状,一想到未来,你又没有信心狠下心来在当下努力。 得走出这种状态,不能一直困在那里面,哪不行就去提升哪,你一动不动那指定改变不了未来,动起来,积少成多才能越来越好
点赞 评论 收藏
分享
评论
3
收藏
分享

创作者周榜

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