https://www.hackerrank.com/challenges/occupations/problem?isFullScreen=true
select max(case when t.occupation = "Doctor" then t.name else null end) as "doctor"
,max(case when t.occupation = "Professor" then t.name else null end) as "professor"
,max(case when t.occupation = "Singer" then t.name else null end) as "singer"
,max(case when t.occupation = "Actor" then t.name else null end) as "actor"
from (select o.*
,row_number() over (partition by o.occupation order by o.name) idx
from occupations o) t
group by t.idx