make 3 rows, 1 column from 1 row 3 colums

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!

>Solution :

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

Leave a Reply