Home > other >  make 3 rows, 1 column from 1 row 3 colums
make 3 rows, 1 column from 1 row 3 colums

Time:11-09

I have following table in db2:

id person 1 person 2 person 3
1 10 12 15

I now want to make a query that returns the following:

id person
1 10
1 12
1 15

how can I do this in db2?

Thanks in advance!

CodePudding user response:

Use a UNION:

select id, person1 as person
from the_table
union all 
select id, person2
from the_table
union all 
select id, person3
from the_table
  • Related