---union all 解法
select
date,
count(distinct user_id) as new
from
(select
user_id,
min(date) as date
from login
group by
user_id
) as a
group by date
union
select
date,
'0' as new
from login
where date not in (
select
min(date) as date
from login
group by
user_id
)
order by date

京公网安备 11010502036488号