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

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

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

黔驴技穷了,主要对空值函数不熟悉
select
m
,count(user_id)
from (
select
user_id
,min(date) m
from login
group by user_id
) a
group by a.m
#结果正确 但不带没有日期的值

select
b.date
,c2-ifnull(c1,0)
from (
select
date
,count(user_id) c2
from login
group by date
) b
left join (
select
a.date
,count(user_id) c1
from (
select
*
,min(date) over(partition by user_id) m
from login
) a
where a.date <>a.m
group by a.date
) c
on b.date =c.date

全部评论

相关推荐

孙艹肘:校招不给三方直接让实习我都去了,,主打一个在学校呆着也是闲着,不如出来实习一下
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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