1. 程式人生 > >儲存過程用到的表、分組、排序、聯結

儲存過程用到的表、分組、排序、聯結

查詢儲存過程用到的表,並進行分組、排序、聯結:

 1  SELECT  
 2       REFERENCED_OWNER,
 3       REFERENCED_NAME,
 4       LISTAGG(XH||'>'||NAME,',') WITHIN GROUP(ORDER BY  XH ) NAME 
 5  FROM 
 6      ( 
 7         SELECT 
 8         A.REFERENCED_OWNER, 
 9         A.REFERENCED_NAME, 
10         A.NAME ,
11         ROW_NUMBER() OVER
(PARTITION BY A.REFERENCED_OWNER, A.REFERENCED_NAME ORDER BY A.NAME DESC ) XH 12 FROM USER_DEPENDENCIES A --系統表 13 WHERE A.REFERENCED_OWNER IN ('IRS_MODEL', 'IRS_ODS','ADMDATA') --根據實際使用者 14 AND TYPE IN ('PROCEDURE'/*, 'VIEW'*/) --實際類別 15 AND A.NAME LIKE 'PMODEL_DS%'
--實際名稱 16 ORDER BY A.REFERENCED_OWNER,A.REFERENCED_NAME 17 ) 18 GROUP BY REFERENCED_OWNER,REFERENCED_NAME;