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) as DOCTOR,
max(CASE WHEN OCCUPATION= 'Professor' then name end) as Profrssor,
max(CASE WHEN OCCUPATION= 'Singer' then name end) as Singer ,
max(CASE WHEN OCCUPATION= 'Actor' then name end) as Actor
from (
select NAME,OCCUPATION,row_number()over(partition by occupation order by name) rn from occupations)
group by rn
order 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 end) as DOCTOR, max(CASE WHEN OCCUPATION= 'Professor' then name end) as Profrssor, max(CASE WHEN OCCUPATION= 'Singer' then name end) as Singer , max(CASE WHEN OCCUPATION= 'Actor' then name end) as Actor from ( select NAME,OCCUPATION,row_number()over(partition by occupation order by name) rn from occupations) group by rn order by rn;