新加一列注册日期,注册日期就是登入日期最小值,统计登入日期等于注册日期的行 select date ,sum(if(date=reg_date,1,0)) as new from ( select user_id ,date ,min(date) over (partition by user_id) as reg_date from login ) as a group by date