The fuction of listagg.
来源:互联网 发布:淘宝 装修市场 编辑:程序博客网 时间:2024/05/22 11:02
LISTAGG
orders data within each group specified in the ORDER
BY
clause and then concatenates the values of the <measure> column.
As a single-set aggregate function,
LISTAGG
operates on all rows and returns a single output row.As a group-set aggregate, the function operates on and returns an output row for each group defined by the
GROUP
BY
clause.As an analytic function,
LISTAGG
partitions the query result set into groups based on one or more expression in thequery_partition_clause
.
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL> ed
已写入 file afiedt.buf
1 select deptno, listagg(job,';') within group (order by job) jobs
2 from scott.emp
3 group by deptno
4* order by deptno
SQL> /
DEPTNO
----------
JOBS
--------------------------------------------------------------------------------
10
CLERK;MANAGER;PRESIDENT
20
ANALYST;ANALYST;CLERK;CLERK;MANAGER
30
CLERK;MANAGER;SALESMAN;SALESMAN;SALESMAN;SALESMAN
We can use the distinct in the sub query to remove the duplicated records.
SQL> ed
已写入 file afiedt.buf
1 select deptno, listagg(job,';') within group (order by job) jobs
2 from (select distinct deptno, job from scott.emp)
3 group by deptno
4* order by deptno
SQL> /
DEPTNO
----------
JOBS
--------------------------------------------------------------------------------
10
CLERK;MANAGER;PRESIDENT
20
ANALYST;CLERK;MANAGER
30
CLERK;MANAGER;SALESMAN
- The fuction of listagg.
- The study of calling fuction in Python(20170907)
- LISTAGG
- listagg
- listagg
- listagg函数
- LISTAGG函数
- listagg函数
- LISTAGG 行转列
- socket fuction
- strstr fuction
- Strange fuction
- hdu2899Strange fuction
- Strange fuction
- hdu2899_Strange fuction
- Strange fuction
- Strange fuction
- acm_1002_Strange fuction
- 2.2 lamps
- spring3.0使用annotation完全代替XML
- XML Schema 中空值的表示
- 防止用户注销后后退到原来页面的javascript与jsp解决方案
- 双城记
- The fuction of listagg.
- ASP.NET大文件上传
- PC中如何判断网络已经连接或者断开
- 书C#
- test
- 客户端cookie不可用时,解决方案
- SDIO DRIVER
- SVN入门及配置使用
- 常用正则表达式