更新 これをお探しですか?
CREATE VIEW vw_rain_stats
AS
SELECT TRUNC(rain_date, 'MM') rain_date,
SUM(amt) amt
FROM rain_stats
GROUP BY TRUNC(rain_date, 'MM')
;
2012年の月額を取得する
SELECT rain_date,
amt,
SUM(amt) OVER (ORDER BY rain_date) running_amt
FROM vw_rain_stats
WHERE rain_date BETWEEN '01-JAN-12' AND '01-DEC-12';
2011年12月から月額を取得
SELECT rain_date,
amt,
SUM(amt) OVER (ORDER BY rain_date) running_amt
FROM vw_rain_stats
WHERE rain_date >= '01-DEC-11';
サンプル出力:
| RAIN_DATE | AMT | RUNNING_AMT |
------------------------------------------
| December, 01 2011 | 80 | 80 |
| January, 01 2012 | 30 | 110 |
| February, 01 2012 | 70 | 180 |
| March, 01 2012 | 110 | 290 |
| .................. | ... | ........... |
これが