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

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

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

SELECT 
	uid,
	SUM(IF(submit_time IS NULL, 1, 0)) AS incomplete_cnt,
	SUM(IF(submit_time IS NULL, 0, 1)) AS complete_cnt,
	GROUP_CONCAT(DISTINCT CONCAT(DATE_FORMAT(start_time,'%Y-%m-%d'),':',tag) SEPARATOR';') detail
FROM 
	exam_record a JOIN examination_info b ON a.exam_id = b.exam_id
WHERE YEAR(start_time)='2021'
GROUP BY uid
HAVING
	incomplete_cnt > 1
	AND incomplete_cnt < 5
	and complete_cnt >= 1
ORDER BY incomplete_cnt DESC;

全部评论

相关推荐

点赞 评论 收藏
分享
耀孝女:就是你排序挂了
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务