请教一句oracle查询sql
表里的数据记录为 月份,营业额
如 一月,100
二月,200
三月,400
四月,500。
查询目标:月份,营业额,总营业额
如,一月,100,100
二月,200,300
三月,400,700
四月,500,1200
求sql
[解决办法]
WITH t1 AS
(SELECT '1' MTH,100 AMT FROM DUAL UNION ALL
SELECT '2' MTH,200 AMT FROM DUAL UNION ALL
SELECT '3' MTH,400 AMT FROM DUAL UNION ALL
SELECT '4' MTH,500 AMT FROM DUAL)
SELECT T1.*,SUM(AMT) OVER(ORDER BY T1.MTH) FROM T1;