题解 | #牛客每个人最近的登录日期(四)#
牛客每个人最近的登录日期(四)
https://www.nowcoder.com/practice/e524dc7450234395aa21c75303a42b0a
with
t2 as (
select
l.*,
if (l.date = t1.date, 1, null) as is_one
from
login as l
left join (
select
user_id,
min(date) as date
from
login
group by
user_id
) as t1 on l.user_id = t1.user_id
)
select
date,
count(is_one) as new
from
t2
group by
date
order by
date