-- ORACLE 누적합 ( 집계 함수의 윈도우 옵션 )
WITH TA AS
( SELECT 1 IDX, 1 VAL FROM DUAL
UNION ALL SELECT 2 IDX, 2 VAL FROM DUAL
UNION ALL SELECT 3 IDX, 3 VAL FROM DUAL
UNION ALL SELECT 4 IDX, 4 VAL FROM DUAL
)
SELECT
IDX
, VAL
, SUM ( VAL )
OVER ( ORDER BY IDX ASC
RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) "SUM_ASC"
, SUM ( VAL )
OVER ( ORDER BY IDX DESC
RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING ) "SUM_DESC"
FROM TA
ORDER BY IDX ASC
'DB > Oracle' 카테고리의 다른 글
[Oracle] 플랜 확인방법 (0) | 2011.11.29 |
---|---|
[Oracle] 오라클 힌트 정리표 (0) | 2011.11.29 |
[LINUX] ORACLE 삭제 (0) | 2011.06.29 |
[LINUX] ORACLE 설치 (9i, 10g, 11g) (0) | 2011.06.28 |
[LINUX] ORACLE 설치와 활용 - 2 (0) | 2011.06.28 |