题解 | #任意两个连续自然月练题次数大于1的用户#

任意两个连续自然月练题次数大于1的用户

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

select distinct device_id
from
(select device_id, cnt, lead(cnt, 1, 0) over(partition by device_id order by month_now) as cnt_next,
month_now, lead(month_now,1,month_now) over(partition by device_id order by month_now) as mon_next
from 
(select device_id, date_format(event_date, '%Y-%m') as month_now,
count(question_id) as cnt
from question_practice_detail
group by device_id, date_format(event_date, '%Y-%m')) as ta1
) as ta2
where cnt >=2 
and cnt_next>=2
and timestampdiff(month, concat(month_now,'-01'),concat(mon_next,'-01'))=1
order by device_id desc

全部评论

相关推荐

06-12 10:50
门头沟学院 Java
你的不定积分没加C:我怎么在学院群看到了同样的话
点赞 评论 收藏
分享
想熬夜的小飞象在秋招:我觉得这模版挺好啊,可以调大点行距,大佬能不能推荐一下是在哪找的模板
应届生,你找到工作了吗
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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