Oracle?????LISTAGG
???????????? ???????[ 2015/7/20 11:04:28 ] ?????????????
????????????????У???????????????????????????????????????????????????????????÷???
?????÷???
???????????????????????????£?
????For a specified measure?? LISTAGG orders data within each group specified in the ORDER BY clause and then concatenates the values of the measure column.
??????????????????LISTAGG????order by??????????????????????????????????
????measure_expr?????????κλ????е??????
????delimiter????????????NUL
????order_by_clause??order by????????????????????
??????????÷??????????LISTAGG???????????????????????????????????????????
????order_by_clause??query_partition_clause???÷????£?
?????????ú??????о????????
?????????????????????????????????????
????SQL> select listagg(ename??'??')within group(order by sal)name from emp;
????NAME
????----------------------------------------------------------------------------------------------------
????SMITH??JAMES??ADAMS??MARTIN??WARD??MILLER??TURNER??ALLEN??CLARK??BLAKE??JONES??FORD??SCOTT??KING
???????麯????
SQL> select deptno??listagg(ename??'??')within group(order by sal)name from emp group by deptno;
DEPTNO NAME
---------- ----------------------------------------------------------------------------------------------------
10 MILLER??CLARK??KING
20 SMITH??ADAMS??JONES??FORD??SCOTT
30 JAMES??MARTIN??WARD??TURNER??ALLEN??BLAKE
??????????
SQL> select deptno??ename??sal??listagg(ename??'??')within group(order by sal)over(partition by deptno)name from emp;
DEPTNO ENAME SAL NAME
---------- ---------- ---------- ----------------------------------------
10 MILLER 1300 MILLER??CLARK??KING
10 CLARK 2450 MILLER??CLARK??KING
10 KING 5000 MILLER??CLARK??KING
20 SMITH 800 SMITH??ADAMS??JONES??SCOTT??FORD
20 ADAMS 1100 SMITH??ADAMS??JONES??SCOTT??FORD
20 JONES 2975 SMITH??ADAMS??JONES??SCOTT??FORD
20 SCOTT 3000 SMITH??ADAMS??JONES??SCOTT??FORD
20 FORD 3000 SMITH??ADAMS??JONES??SCOTT??FORD
30 JAMES 950 JAMES??MARTIN??WARD??TURNER??ALLEN??BLAKE
30 MARTIN 1250 JAMES??MARTIN??WARD??TURNER??ALLEN??BLAKE
30 WARD 1250 JAMES??MARTIN??WARD??TURNER??ALLEN??BLAKE
30 TURNER 1500 JAMES??MARTIN??WARD??TURNER??ALLEN??BLAKE
30 ALLEN 1600 JAMES??MARTIN??WARD??TURNER??ALLEN??BLAKE
30 BLAKE 2850 JAMES??MARTIN??WARD??TURNER??ALLEN??BLAKE
14 rows selected.
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11