with
tb1 as(
    select user_id, date, rank() over(
        partition by user_id
        order by date
    ) as rk
    from login
),
tb2 as(
    select distinct date from login
),
tb3 as(
    select date, count(*) as new from tb1
    where rk = 1
    group by date
)
select tb2.date, ifnull(new, 0) as new from tb2
left join tb3 on tb2.date = tb3.date