题解 | #未完成试卷数大于1的有效用户#主要是group_concat函数的用法

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

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

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,
    group_concat(distinct concat_ws(':',date_format(start_time,'%Y-%m-%d'),t2.tag ) separator ';') as detail
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
order by incomplete_cnt desc

全部评论

相关推荐

10-11 14:44
济南大学 Java
点赞 评论 收藏
分享
否极泰来来来来:解约赔多少
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

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