select date, count(distinct case when date = first_login_date then user_id else null end) as new from ( select user_id, date, first_value(date) over(partition by user_id) as first_login_date from login ) t0 group by date order by date asc 考察开窗函数first_value;注意处理某一天没有用户登录的情况