• + 0 comments

    with cte as (select *, row_number() over(partition by occupation order by name) rn from occupations)

    select max(case when occupation = 'Doctor' then name end) as doctor
    , max(case when occupation = 'Professor'then name end )as professor , max(case when occupation ='Singer' then name end ) as singer , max(case when occupation = 'Actor' then name end) as actor from cte group by rn order by rn