窗口函数 + join + 子查询 select u.name as u_n, t.date, t.ps_num from (select *, sum(number)over(partition by user_id order by date) as ps_num from passing_number ) t join user u on t.user_id = u.id order by t.date,u.name;