Prepare > SQL > Advanced Select > Occupations

2023. 5. 16. 20:21HackerRank-My SQL

#문제

Pivot the Occupation column in OCCUPATIONS so that each Name is sorted alphabetically and displayed underneath its corresponding Occupation. The output column headers should be Doctor, Professor, Singer, and Actor, respectively.

 

=> 의사, 교수, 가수, 배우 로 열 이름을 정하고,  열 이름 밑에 알파벳순 이름을 보이게 OCCUPATIONS를 피벗하라.

 

SELECT Occupation FROM OCCUPATIONS
GROUP BY Occupation;
Professor
Actor
Doctor
Singer

한계를 느끼고

서브쿼리 - 피벗테이블 만들기(행/렬 전환)을 먼저 공부하기로 함