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

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

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

select device_id
from (
    select date1, device_id, num, 
            lag(date1, 1) over(partition by device_id order by date1 asc) as date2
    from (
        select substr(event_date,1,7) as date1,device_id, count(*) as num
        from question_practice_detail
        group by substr(event_date,1,7),device_id
        having count(*)>1
    ) as t
) as t1
where (substr(date1,6,2) - substr(date2,6,2) = 1) or (substr(date1,6,2) - substr(date2,6,2) = -11)
order by device_id desc
;



全部评论

相关推荐

仁者伍敌:难怪小公司那么挑剔,让你们这些大佬把位置拿了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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