with p as (
select 1 person_id, '2221111111' primary_phone, '5551111111' secondary_phone, '9991111111' tertiary_phone
from dual
)
select *
from p
unpivot (
phone_number
for phone_type in (
primary_phone as 'Primary',
secondary_phone as 'Secondary',
tertiary_phone as 'Tertiary'
)
)
PERSON_ID | PHONE_TYPE | PHONE_NUMBER | 1 | Primary | 2221111111 | 1 | Secondary | 5551111111 | 1 | Tertiary | 9991111111 |
---|
with p as (
select 1 person_id, '2221111111' primary_phone, '5551111111' secondary_phone, '9991111111' tertiary_phone
from dual
)
select person_id,
phone_number,
phone_type
from p
unpivot (
phone_number
for phone_type in (
primary_phone as 'Primary',
secondary_phone as 'Secondary',
tertiary_phone as 'Tertiary'
)
)
PERSON_ID | PHONE_NUMBER | PHONE_TYPE | 1 | 2221111111 | Primary | 1 | 5551111111 | Secondary | 1 | 9991111111 | Tertiary |
---|
with p as (
select 1 person_id, '2221111111' primary_phone, '5551111111' secondary_phone, '9991111111' tertiary_phone
from dual
union all
select 2, '2221111112' primary_phone, '5551111112' secondary_phone, '9991111112' tertiary_phone
from dual
)
select person_id,
phone_number,
phone_type
from p
unpivot (
phone_number
for phone_type in (
primary_phone as 'Primary',
secondary_phone as 'Secondary',
tertiary_phone as 'Tertiary'
)
)
PERSON_ID | PHONE_NUMBER | PHONE_TYPE | 1 | 2221111111 | Primary | 1 | 5551111111 | Secondary | 1 | 9991111111 | Tertiary | 2 | 2221111112 | Primary | 2 | 5551111112 | Secondary | 2 | 9991111112 | Tertiary |
---|