oracle10g聚集函数,单列多行合并
从来不写笔记,最近发现越来越健忘,特此记录一下备查
单列数据多行合并为一行的oracle sql:
SELECT wmsys.wm_concat (t.id) as result FROM test t
结果:
0001ZS1000000001B739,0001ZS1000000001B72S,0001ZS1000000001B72T
树形数据层次展现
11AAA
22BBB1
31ABC
43CCC1
52DDD1
621AVC2
select id, sys_connect_by_path(id, '/')
from test
start with pid is null
CONNECT BY prior id = pid
结果:
11/1
22/1/2
321/1/2/21
43/1/3
52/1/2
621/1/2/21
71/1
82/1/2
921/1/2/21
103/1/3
112/1/2
1221/1/2/21