• + 0 comments
    select  max(Doctor),  max(Professor), max(Singer),  max(actor) from (
    select 
        case when Occupation = 'Actor' then name else null end as actor,
        case when Occupation = 'Doctor' then name else null end as Doctor,
        case when Occupation = 'Professor' then name else null end as Professor,
        case when Occupation = 'Singer' then name else null end as Singer,
        RANK() over (PARTITION BY Occupation order by name asc) as rnk
    from 
    OCCUPATIONS ) t
    group by rnk
    order by rnk;