[20111220]listagg 11G的新特性.txt
[20111220]listagg 11G的新特性.txt
顯示相關的資料在一行,找到一個站點,總結了N多方法:
我第一個知道的是:
SELECT deptno,
LTRIM(MAX(SYS_CONNECT_BY_PATH(ename,','))
KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
FROM (SELECT deptno,
ename,
ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ename) AS curr,
ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ename) -1 AS prev
FROM emp)
GROUP BY deptno
CONNECT BY prev = PRIOR curr AND deptno = PRIOR deptno
START WITH curr = 1;
後來瞭解了wmsys.wm_concat函式:
SELECT deptno,wmsys.wm_concat(ename) AS employees FROM emp GROUP BY deptno;
現在11G加入了listagg,感覺這個分析函式比wm_concat靈活一點,就是可以定義分割符號。
Select deptno,listagg(ename,'!') within group (order by sal) enames from emp group by deptno ;
顯示相關的資料在一行,找到一個站點,總結了N多方法:
我第一個知道的是:
SELECT deptno,
LTRIM(MAX(SYS_CONNECT_BY_PATH(ename,','))
KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
FROM (SELECT deptno,
ename,
ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ename) AS curr,
ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ename) -1 AS prev
FROM emp)
GROUP BY deptno
CONNECT BY prev = PRIOR curr AND deptno = PRIOR deptno
START WITH curr = 1;
後來瞭解了wmsys.wm_concat函式:
SELECT deptno,wmsys.wm_concat(ename) AS employees FROM emp GROUP BY deptno;
現在11G加入了listagg,感覺這個分析函式比wm_concat靈活一點,就是可以定義分割符號。
Select deptno,listagg(ename,'!') within group (order by sal) enames from emp group by deptno ;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-713595/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle11.2新特性之listagg函式Oracle函式
- [20131017]11G下truncate的新特性.txt
- 【ORACLE新特性】11G 分割槽新特性Oracle
- oracle 11g 的新特性Oracle
- Oracle 11g 新特性Oracle
- Oracle 11g 新聚集函式listagg實現列轉行Oracle函式
- 11g data guard 新特性
- 11g新特性--active dataguard
- 11G新特性:FLASHBACK ARCHIVEHive
- [20111220]tnsnames.ora的定位.txt
- 11G新特性,待定的統計資訊
- 11G Flashback Data Archive新特性的研究Hive
- 11g新特性:Pending Statistics
- Oracle 11g 新特性簡介Oracle
- Oracle 11g 新特性之DRCPOracle
- 11g 新特性—— Active Database DuplicationDatabase
- Oracle 11g新特性:Result CacheOracle
- 11g新特性--result caching
- Oracle 11g 新特性(轉載)Oracle
- 11G新特性:FLASHBACK ARCHIVE - 01Hive
- 11G新特性:FLASHBACK ARCHIVE – 02Hive
- Oracle 11g新特性之SecureFilesOracle
- 11g新特性:不可視索引索引
- 11g新特性--pending statistics
- [20130730]11G的DRCP特性.txt
- goldengate 11g patch set 1的新特性Go
- Oracle 11g的新特性分割槽:System PartitionOracle
- oracle DG 11g新特性彙總Oracle
- ORACLE 11G新特性之列新增操作Oracle
- 【11g新特性】(I/O calibration)
- Oracle 11g 新特性 -- SecureFiles 說明Oracle
- 11g新特性--invisible indexIndex
- oracle 11g 新特性 表壓縮Oracle
- 【DataGuard】11g 新特性:Active Data Guard
- 11G 新特性: 新加的提示 CHANGE_DUPKEY_ERROR_INDEXErrorIndex
- 新特性:/dev/shm對Oracle 11g的影響devOracle
- 【11g新特性】DDL_LOCK_TIMEOUT的作用
- 11G result cache新特性的更多深入研究