데이터는 555번을 보시면됩니다.
대수는 CTCODE별 NO의 GROUP BY 한값입니다.
SELECT
CASE SEQ WHEN 1 THEN DENSE_RANK() OVER(ORDER BY CTCODE) END
NO,
case SEQ when 1 then CTCODE end CTCODE,
case SEQ when 1 then '기간' else '일반' end GUBUN,
case SEQ when 1 then NUM1 when 2 then NUM2 end NUM,
case SEQ when 1 then CHAMT1 when 2 then CHAMT2 end CHAMT
(CASE SEQ WHEN 1 THEN CHAMT1
WHEN 2 THEN CHAMT2
END) * 100 / SUM(CASE SEQ
WHEN 1 THEN CHAMT1
WHEN 2 THEN CHAMT2
END)
OVER(PARTITION BY NO) PERCENT
FROM (
SELECT CTCODE,
COUNT(DISTINCT (CASE SUBSTR(VDCODE,3,3) WHEN '999' THEN NULL ELSE
SEQ END)) AS NUM1,
VALUE(SUM(CASE SUBSTR(VDCODE,3,3) WHEN '999' THEN 0 ELSE CHAMT
END),0) as CHAMT1
COUNT(DISTINCT (CASE SUBSTR(VDCODE,3,3) WHEN '999' THEN NO))
NUM2,
VALUE(SUM(CASE SUBSTR(VDCODE,3,3) WHEN '999' THEN CHAMT END),0) as
CHAMT2
FROM SALELIB.SALETRS
WHERE HISA='11' AND UPSO ='12' AND DATE = '20051101'
GROUP BY CTCODE) A,
(SELECT 1 SEQ FROM DUAL UNION ALL SELECT 2 NO FROM DUAL) B
에러가 납니다.
Error: SQL0104 - Token OVER was not valid. Valid tokens: END.
(State:37000, Native Code: FFFFFF98)
문법상에 잘못된점 있으면 지적좀 해주세요...
|