简体   繁体   中英

oracle sql how combine column string value

i have records

id | key | string column
------------------------
1  | 1   | A
------------------------
1  | 1   | B
------------------------
1  | 1   | C

i want result like below

id | key | string column
------------------------
1  | 1   | A, B, C
------------------------

someone know how to do? thank you

You are looking for listagg() :

select id, key, listagg(string, ', ') within group (order by string)
from t
group by id, key;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM