MISE À JOUR Vous cherchez ça ?
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')
;
Obtenez les montants mensuels pour l'année 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';
Obtenez des montants mensuels à partir de décembre 2011
SELECT rain_date,
amt,
SUM(amt) OVER (ORDER BY rain_date) running_amt
FROM vw_rain_stats
WHERE rain_date >= '01-DEC-11';
Exemple de sortie :
| 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 |
| .................. | ... | ........... |
Voici SQLFiddle démo