2011년 7월 5일 화요일
년월일에 따른 수량/금액 나오기
SELECT DECODE('Y', 'Y', SUBSTR(create_dt, 1, 4), 'M', SUBSTR(create_dt, 1, 6), 'D', SUBSTR(create_dt, 1, 8), create_dt) nm,
'수량' c11n,
NVL(cnt, 0) c11,
'금액' c21n,
NVL(expect_amt, 0) c21
FROM (SELECT TO_CHAR(create_dt, 'YYYY') create_dt ,
COUNT(*) cnt,
SUM(expect_amt) expect_amt
FROM (SELECT *
FROM qis_pl_receipt
WHERE 1 = 1
AND TO_CHAR(create_dt, 'YYYYMMDD') >= '20090000'
AND TO_CHAR(create_dt, 'YYYYMMDD') <= '20119999'
)
WHERE 1 = 1
GROUP BY TO_CHAR(create_dt, 'YYYY')
)
WHERE 1 = 1
ORDER BY create_dt
피드 구독하기:
댓글 (Atom)
댓글 없음:
댓글 쓰기