题解 | #近三个月未完成试卷数为0的用户完成情况#

近三个月未完成试卷数为0的用户完成情况

https://www.nowcoder.com/practice/4a3acb02b34a4ecf9045cefbc05453fa


1、 dense_rank() 相同排序+连续
1,1,2,3

select uid,count(*) exam_complete_cnt
from(
			select id,uid,exam_id,start_time,DATE_FORMAT(start_time,'%Y-%m-01') start_days,submit_time,score,rn
			from 
			(
			select id,uid,exam_id,start_time,DATE_FORMAT(start_time,'%Y-%m-01') start_days,submit_time,score,
			DENSE_RANK() over(partition by uid order by DATE_FORMAT(start_time,'%Y-%m-01') desc) rn

			from exam_record) a
			where rn<=3
) a1
group by uid
having count(*)=count(submit_time)
order by exam_complete_cnt desc,uid desc


全部评论

相关推荐

牛客100866号技...:把电科加粗,把电科加粗,把电科加粗,两个吊车尾的项目合并成一个,再加一个管理系统。电科✌🏻在成都面中厂手拿把掐
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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