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