题解 | #重点:窗口函数:查用户刷题日期和下一次刷题日期#

查询用户刷题日期和下一次刷题日期

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

select
    a.`user_id`,
    a.`date`,
    a.`nextdate`
from
    (
        select
            `user_id`,
            `date`,
            (
                lead (`date`, 1) over (
                    partition by
                        `user_id`
                    order by
                        `date` asc
                )
            ) as `nextdate`
        from
            questions_pass_record
    ) as a
order by
    a.`user_id`,
    a.`date`

全部评论

相关推荐

挥毫自在:想白嫖你呢
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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