sql script
select l.date, coalesce(count(user_id),0)
from (select distinct date from login) l left join (select user_id, min(date) as date
from login
group by user_id) tmp on l.date=tmp.date
group by date 
select l.date, coalesce(count(user_id),0)
from (select distinct date from login) l left join (select user_id, min(date) as date
from login
group by user_id) tmp on l.date=tmp.date
group by date