We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- SQL
- Advanced Select
- Occupations
- Discussions
Occupations
Occupations
Sort by
recency
|
2141 Discussions
|
Please Login in order to post a comment
select max(case when t.occupation ='Doctor' then t.name end) as Doctor, max(case when t.occupation ='professor' then t.name end ) as professor, max(case when t.occupation ='singer' then t.name end) as singer, max(case when t.occupation ='actor' then t.name end) as actor from ( select occupation ,name , row_number() over (partition by occupation order by name) as rn from occupations ) as t group by rn
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;
My Solution:
) as PO