先连接表,过滤出需要统计的行,然后用窗口函数根据name分组,组内通过日期升序排序。用sum()计算统计至今为止做过的题,最后按照日期升序排序
select name,date,sum(number) over(partition by name order by date asc) as ps_num
from(
select name,a.date,number
from login a,passing_number b,user c
where b.user_id=a.user_id and a.date=b.date and c.id=a.user_id
)a
order by date asc

京公网安备 11010502036488号