https://www.hackerrank.com/challenges/occupations/problem?isFullScreen=true


select max(case when o.occupation = 'Doctor' then o.name else null end) as "Doctor"
,max(case when o.occupation = 'Professor' then o.name else null end) as "Professor"
,max(case when o.occupation = 'Singer' then o.name else null end) as "Singer"
,max(case when o.occupation = 'Actor' then o.name else null end) as "Actor"
from (
select name
,occupation
,row_number() over (partition by occupation order by name) as idx
from occupations) o
group by o.idx
order by o.idx;
