题解 | #牛客每个人最近的登录日期(四)#
牛客每个人最近的登录日期(四)
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;
注意处理某一天没有用户登录的情况