题解 | #牛客每个人最近的登录日期(四)#

牛客每个人最近的登录日期(四)

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

select
    date,
    count(distinct case when date = first_login_date then user_id else null end) as new
from
(
select 
    user_id,
    date,
    first_value(date) over(partition by user_id) as first_login_date
from login
) t0
group by date
order by date asc

考察开窗函数first_value;

注意处理某一天没有用户登录的情况

全部评论

相关推荐

头像
04-29 10:53
已编辑
东北大学 自动化类
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务