美文网首页
Leetcode 1454. 活跃用户

Leetcode 1454. 活跃用户

作者: 七齐起器 | 来源:发表于2021-12-20 19:22 被阅读0次
1454.png

https://leetcode-cn.com/problems/active-users/

with tmp as (select id,login_date from Logins group by id,login_date)

select distinct a.id,b.name 
from (
select a.id,a.dif,count(*)dif1 from (
select 
a.id
,(datediff(a.login_date,c.f_date)+1-row_number() over(partition by a.id order by a.login_date)) dif
from tmp a left join tmp b 
on a.id=b.id and date_add(a.login_date,interval 1 day)=b.login_date
left join (select id,min(login_date)f_date from tmp group by id )c on a.id=c.id
where b.id is not null 
)a group by a.id,a.dif
)a left join Accounts b on a.id=b.id 
where a.dif1>=4 and b.id is not null 
order by a.id 
1454.png

相关文章

网友评论

      本文标题:Leetcode 1454. 活跃用户

      本文链接:https://www.haomeiwen.com/subject/agbzfrtx.html