题解 | #任意两个连续自然月练题次数大于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-10 15:24
高考前一晚在OPPO手机上设置了早上5:30的闹钟,然而闹钟并未按时响起。直到妈妈做好早餐后,在6:27打开手机才发现闹钟未触发,“气得早上饭都没吃”。资本家你赢了
永不遗忘:我来解释一下 :Oppo 手机晚上两点会自动进行系统更新,这个系统更新会重置掉所有设置好的闹钟,而且他也不会告诉你,而且只有 Oppo 会这样,华为苹果小米三星都不会
点赞 评论 收藏
分享
爱吃肉的伊登在写日记:好棒,27届简历能做成这个样子,但是第一个项目感觉cover住难度还是不小的,特别是二面的时候肯定要对分布式系统设计这一块儿有高出正常面试者的水平才行
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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