Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

To concatenate columns

User910243567Dec 22 2022 — edited Jan 16 2023

Hello
I have below requirement where i need to concatenate column values for common names. Can you please suggest.

with t1 
as
(
select 'SK' Name, 'reading' activity from dual
UNION ALL
select 'SK', 'writing' activity from dual
UNION ALL
select 'NK', 'Soccer' activity from dual
UNION ALL
select 'TK', 'golf' activity from dual
UNION ALL
select 'TK', 'Printing' from dual
UNION ALL
select 'TK', 'copying' from dual
)
select * from t1;

expecting below output.

NAME     Activities
---------------------
SK       reading, writing
NK       Soccer
TK       golf, Printing, copying

Thanks for your time.

This post has been answered by Stax on Dec 22 2022
Jump to Answer
Comments
Post Details
Added on Dec 22 2022
1 comment
111 views