题解 | -union all 解法

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

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

---union all 解法
select
date,
count(distinct user_id) as new
from
(select
user_id,
min(date) as date
from login
group by
user_id
) as a
group by date
union
select
date,
'0' as new
from login
where date not in (
select
min(date) as date
from login
group by
user_id
)

order by date

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务