Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Usage of oracle wm_concat function

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The wmsys.wm_concat function, which functions as a', 'link character

Examples are as follows:

SQL > create table idtable (id number,name varchar2 (30))

Table created

SQL > insert into idtable values (10)

1 row inserted

SQL > insert into idtable values (10gramme bc')

1 row inserted

SQL > insert into idtable values (10)

1 row inserted

SQL > insert into idtable values (20 minutes later)

1 row inserted

SQL > insert into idtable values (20 ~ (th))

1 row inserted

SQL > insert into idtable values (20m MN')

1 row inserted

SQL > select * from idtable

ID NAME

10 ab

10 bc

10 cd

20 hi

20 ij

20 mn

6 rows selected

SQL > select id,wmsys.wm_concat (name) name from idtable

2 group by id

ID NAME

-

10 ab,bc,cd

20 hi,ij,mn

SQL > select id,wmsys.wm_concat (name) over (order by id) name from idtable

ID NAME

-

10 ab,bc,cd

10 ab,bc,cd

10 ab,bc,cd

20 ab,bc,cd,hi,ij,mn

20 ab,bc,cd,hi,ij,mn

20 ab,bc,cd,hi,ij,mn

6 rows selected

SQL > select id,wmsys.wm_concat (name) over (order by id,name) name from idtable

ID NAME

-

10 ab

10 ab,bc

10 ab,bc,cd

20 ab,bc,cd,hi

20 ab,bc,cd,hi,ij

20 ab,bc,cd,hi,ij,mn

6 rows selected

Personally, I find this usage more interesting.

SQL > select id,wmsys.wm_concat (name) over (partition by id) name from idtable

ID NAME

-

10 ab,bc,cd

10 ab,bc,cd

10 ab,bc,cd

20 hi,ij,mn

20 hi,ij,mn

20 hi,ij,mn

6 rows selected

SQL > select id,wmsys.wm_concat (name) over (partition by id,name) name from idtable

ID NAME

-

10 ab

10 bc

10 cd

20 hi

20 ij

20 mn

6 rows selected

Original address: http://bbs.delit.cn/thread-206-1-1.html

Please indicate the source of the reprint:

Written by: measurement Technology http://www.delit.cn

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report