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 end),
max(case when occupation = 'professor' then name end),
max(case when occupation = 'Singer' then name end),
max(case when occupation = 'Actor' then name end)
from (
Select *,
Rank() over(partition by occupation order by name) as rank
from Occupations
) as o
group by rank
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 end), max(case when occupation = 'professor' then name end), max(case when occupation = 'Singer' then name end), max(case when occupation = 'Actor' then name end) from ( Select *, Rank() over(partition by occupation order by name) as rank from Occupations ) as o group by rank