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.
select max(case when Occupation = 'Doctor'
then Name else null end) as Doctor,
max(case when Occupation = 'Professor'
then Name else null end) as Professor,
max(case when Occupation = 'Singer'
then Name else null end) as Singer,
max(case when Occupation = 'Actor'
then Name else null end) as Actor
from(
select Name, Occupation,
row_number() over (partition by Occupation order by Name) as rn
from OCCUPATIONS
) as x
group by 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 →
select max(case when Occupation = 'Doctor' then Name else null end) as Doctor, max(case when Occupation = 'Professor' then Name else null end) as Professor, max(case when Occupation = 'Singer' then Name else null end) as Singer, max(case when Occupation = 'Actor' then Name else null end) as Actor from( select Name, Occupation, row_number() over (partition by Occupation order by Name) as rn from OCCUPATIONS ) as x group by rn