오라클 누적합 구하기
SELECT SUM(VOL_EACH) OVER (ORDER BY ROWID) AS VOL , VOL_EACH , AREA , ELEV FROM ( SELECT CASE WHEN LAG(ELEV,1,0) OVER (ORDER BY ELEV ASC) = 0 THEN 0 ELSE ((AREA + (LAG(AREA,1,0) OVER (ORDER BY AREA ASC)) ) * (ELEV - (LAG(ELEV,1,0) OVER (ORDER BY ELEV ASC))) ) / 2.0 END AS VOL_EACH , AREA , ELEV , IVOL_SEQ , RSVR_CODE FROM ANL_RSVR_IVOL ) 결론은 SUM(VOL_EACH) OVER (ORDER BY ROWID)
2011. 11. 25.