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
min(if (occupation = "Doctor",name,null)) as Doctor,
min(if (occupation = "Professor",name,null)) as Professor,
min(if (occupation = "Singer",name,null)) as Singer,
min(if (occupation = "Actor",name,null)) as Actor
from
(select name,occupation,Row_number() over(partition by occupation order by name) as row_num
from occupations) as ord group by row_num;
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 min(if (occupation = "Doctor",name,null)) as Doctor, min(if (occupation = "Professor",name,null)) as Professor, min(if (occupation = "Singer",name,null)) as Singer, min(if (occupation = "Actor",name,null)) as Actor from (select name,occupation,Row_number() over(partition by occupation order by name) as row_num from occupations) as ord group by row_num;