SELECT A.YYYYMM,A.ITEM_CD,B.RECV_PRICE
FROM (
SELECT Max(SubStr(B.RECV_DATE,1,6)) YYYYMM,A.ITEM_CD
FROM TB_CMSM_A_032 A
LEFT OUTER JOIN TB_CMSM_A_030 B ON A.SAUP_CD = B.SAUP_CD AND A.RECV_NO = B.RECV_NO
GROUP BY A.ITEM_CD
) A
LEFT OUTER JOIN (
SELECT Max(SubStr(B.RECV_DATE,1,6)) YYYYMM,A.ITEM_CD,A.RECV_PRICE
FROM TB_CMSM_A_032 A
LEFT OUTER JOIN TB_CMSM_A_030 B ON A.SAUP_CD = B.SAUP_CD AND A.RECV_NO = B.RECV_NO
GROUP BY A.ITEM_CD,A.RECV_PRICE
) B ON A.ITEM_CD = B.ITEM_CD
WHERE A.YYYYMM = B.YYYYMM AND A.ITEM_CD = '921000163'
=====================================================================================================
가장 최근에 입고된 아이탬의 단가를 알고 싶은 문제입니다
위와같이 하면 되긴하는데, 어거지같은 느낌이....
서브쿼리안 A.RECV_PRICE 에 간단한 함수하나 쓰면 될거 같은데 모르겠네요 ㅡ.ㅜ
|