Вы должны использовать GROUP BY
by и COALESCE
:
WITH telephone (id, name, phone_type, phone_number) AS
( SELECT * FROM (VALUES
( 1, 'Austin', 'PR', '789-100-1000'),
( 1, 'Austin', 'CL', '762-100-1009'),
( 2, 'Andrew', 'PR', '565-100-1000'),
( 2, 'Andrew', 'CL', '312-199-6754'),
( 3, 'Kathy' , 'CL', '100-100-1000') ))
select
id as ID,
name as NAME,
COALESCE( max(case when phone_type = 'PR' then 'PR' end),
max(case when phone_type = 'CL' then 'CL' end) ) as PHONE_TYPE,
COALESCE( max(case when phone_type = 'PR' then phone_number end),
max(case when phone_type = 'CL' then phone_number end) ) as PHONE_NUMBER
from telephone
group by id, name
order by id, name
----
Results
ID NAME PHONE_TYPE PHONE_NUMBER
1 Austin PR 789-100-1000
2 Andrew PR 565-100-1000
3 Kathy CL 100-100-1000