Reputation: 339
I have two columns in sql
ID Perils
1 PES
1 PEA
2 PAL
2 PWH
I wanted a query which can get me
ID Perils
1 PES+PEA
2 PAL+PWH
Hence concatenating string with delimitor '+' by pivoting on ID
Upvotes: 1
Views: 36
Reputation: 2566
Group by ID column and concatenate the Perils column. Now the aggregate for doing this is DB-specific. For MySQL, it would be:
select ID, GROUP_CONCAT(Perils) as Perils
from theTable
group by ID
the method for Oracle is listagg().
Upvotes: 1