• + 0 comments

    select max(IF(Occupation='Doctor',Name,NULL)) AS Doctor, MAX(IF(Occupation='Professor',Name,NULL)) as Professor, max(if(Occupation='Singer',Name,NULL)) as Singer, max(if(Occupation='Actor',Name,NULL)) as Actor from (select name,Occupation, ROW_NUMBER() OVER(PARTITION BY Occupation order by Name) as rn from OCCUPATIONS)as temp GROUP BY rn ORDER BY rn;