日期:2014-05-16 浏览次数:20589 次
WITH SUPPLY_TEMP AS (SELECT A.STAT_ID, RANK() OVER(PARTITION BY A.SUBS_ID, A.EQUIP_CATEG, A.EQUIP_CODE_ID ORDER BY A.STAT_DATE DESC) RANK1, B.ORG_NO, B.ORG_NAME, C.SUBS_NAME, A.EQUIP_CATEG, A.EQUIP_CODE_ID, A.STOCK_NUM, A.PLAN_DIST_NUM, A.DISTING_NUM, A.MAX_SS, A.MIN_SS, A.EST_USE_NUM, A.EST_SUPPLY_END_DATE FROM D_SUPPLYDMD_STAT A, O_ORG B, C_SUBS C WHERE A.ORG_NO = B.ORG_NO AND A.SUBS_ID = C.SUBS_ID AND A.STAT_DATE > ADD_MONTHS(SYSDATE, -1) ORDER BY A.ORG_NO) SELECT * FROM SUPPLY_TEMP B WHERE B.RANK1 = 1