분석함수 사용하여 쿼리 해결해주셨는데...기존에 있던 쿼리에 추가하니까
실행속도가 너무 느려서 고민이네요..염치없지만 마농님 어떻게 추가해야 최단시간에
출력될까요..? 추가부분은 굵게 표시했습니다...염치없네요...
SELECT /*+ ORDERED */ ROWNUM,
GSGOCD,
GOGONM,
DECODE(cscokn, '0','원가','1','매가','2','공통') csgokn
FROM (SELECT * FROM SCGOSNTB ORDER BY GSGOCD) A,
(SELECT *
FROM SCGOODTB
WHERE GOSHCD = :P_JUMPO_CD
AND GOMIDD LIKE :P_JUNG_CD || '%'
AND GOSEYN = '0'
AND (GOGOCD LIKE :P_SANG_CD || '%'
OR GOBAC1 LIKE :P_SANG_BCD || '%'
OR GOBAC2 LIKE :P_SANG_BCD || '%') ) B,
(SELECT *
FROM (SELECT csshcd, csgocd, csstdt, cssekn, cscokn, csendt
, ROW_NUMBER() OVER(PARTITION BY csshcd, csgocd
ORDER BY csstdt DESC) rn
FROM sccosttb
)
WHERE rn = 1
) E,
SCCOMMTB C,
SCPRSTTB D
WHERE GSSHCD = :P_JUMPO_CD
AND GSSNDD = :P_BALJU_DT
AND GSSNKN = :P_BALJU_GBN -- 2:권고
AND GSCANO = :P_PYUN_NO
AND GOSHCD = GSSHCD
AND GOGOCD = GSGOCD
AND CMSHCD = GOSHCD
AND CMLRCD = '01'
AND CMMDCD = '21'
AND CMSMCD = GOCUST
AND PSSHCD(+) = :P_JUMPO_CD
AND PSGOCD(+) = GSGOCD
AND GSGOCD = csgocd
ORDER BY gogocd
|