MySQL窗口函数解法 select date, round(ifnull(lead(sum(next_day),1)over(order by date)/sum(new),0),3) from (select date, if(date=(min(date)over(partition by user_id)),1,0) as new, if(date=date_add(min(date)over(partition by user_id),interval 1 day),1,0) as next_day from login) ...