We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
with Doctor as
(
select name,occupation, row_number() over(order by name asc) as rn from occupations where occupation="Doctor"
),
Actor as
(
select name, occupation,row_number() over(order by name asc) as rn from occupations where occupation="Actor"
),
Singer as
(
select name, occupation,row_number() over(order by name asc) as rn from occupations where occupation="Singer"
),
Professor as
(
select name,occupation, row_number() over(order by name asc) as rn from occupations where occupation="Professor"
)
select d.name,p.name,s.name,a.name from Professor p
left join Singer s on s.rn=p.rn
left join Doctor d on d.rn=p.rn
left join Actor a on a.rn=p.rn
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Occupations
You are viewing a single comment's thread. Return to all comments →
with Doctor as ( select name,occupation, row_number() over(order by name asc) as rn from occupations where occupation="Doctor" ), Actor as ( select name, occupation,row_number() over(order by name asc) as rn from occupations where occupation="Actor" ), Singer as ( select name, occupation,row_number() over(order by name asc) as rn from occupations where occupation="Singer" ), Professor as ( select name,occupation, row_number() over(order by name asc) as rn from occupations where occupation="Professor" )
select d.name,p.name,s.name,a.name from Professor p left join Singer s on s.rn=p.rn left join Doctor d on d.rn=p.rn left join Actor a on a.rn=p.rn