데이터 분석/[SQL] 기초
[HackerRank] MySQL - Occupations
INCHELIN
2025. 3. 20. 18:42
728x90
반응형
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 (select name, occupation,
row_number() over(partition by occupation order by name asc) as rn from occupations) as a
group by rn
728x90
반응형