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

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

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

SELECT uid, incomplete_cnt, complete_cnt, (
	SELECT GROUP_CONCAT(DISTINCT DATE(start_time),':',tag ORDER BY start_time SEPARATOR ';')
	FROM exam_record 
	JOIN examination_info USING(exam_id) 
	WHERE YEAR(start_time)=2021 AND uid = complete_t.uid
	) AS detail
FROM (SELECT
	uid, COUNT(submit_time) AS complete_cnt
	FROM exam_record
    WHERE YEAR(start_time)=2021
	GROUP BY uid
) AS complete_t
LEFT JOIN (
	SELECT uid, COUNT(start_time) AS incomplete_cnt
	FROM exam_record
    WHERE submit_time IS NULL AND YEAR(start_time)=2021
	GROUP BY uid
) AS incomplete_t USING(uid)
WHERE complete_cnt >= 1 AND incomplete_cnt < 5 AND incomplete_cnt > 1

全部评论

相关推荐

10-30 23:23
已编辑
中山大学 Web前端
去B座二楼砸水泥地:这无论是个人素质还是专业素质都👇拉满了吧
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
11-27 10:52
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务