1

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

Vasista B
  • 329
  • 1
  • 2
  • 10

1 Answers1

1

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().

DBug
  • 2,502
  • 1
  • 12
  • 25