题解 | #月均完成试卷数不小于3的用户爱作答的类别#

月均完成试卷数不小于3的用户爱作答的类别

https://www.nowcoder.com/practice/b1d13efcfa0c4ecea517afbdb9090845

注释部分是我写的,不知道为什么还有一个实例通过不了,有懂的友友能指正以下吗
# select
#     tag,
#     count(1) tag_cnt
# from
#     exam_record
#     left join examination_info using (exam_id)
# where
#     uid in (
#         select
#             uid
#         from
#             (
#                 select
#                     uid,
#                     count(1) we
#                 from
#                     exam_record
#                 where
#                     score is not null
#                     and month (start_time) = month (submit_time)
#                 group by
#                     uid
#                 having
#                     we > 2
#             ) t
#     )
# group by
#     tag
# order by
#     tag_cnt desc;


SELECT
	b.tag,
	count(*) tag_cnt
FROM
	exam_record a
LEFT JOIN examination_info b ON a.exam_id = b.exam_id
WHERE
	a.uid IN (
		SELECT
			uid
		FROM
			exam_record
		WHERE
			submit_time IS NOT NULL
		GROUP BY
			uid,
			DATE_FORMAT(submit_time, '%Y%m')
		HAVING
			COUNT(submit_time) > 2
	)
GROUP BY
	b.tag
ORDER BY
	tag_cnt DESC

全部评论

相关推荐

2025-12-19 15:04
门头沟学院 Java
小肥罗:hr爱上你了,你负责吗哈哈
点赞 评论 收藏
分享
喵_coding:这实习干啥了? 没写出来一点产出啊 好好回忆一下干了啥 问问ai 问问大佬 准备些话术就好了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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