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
'데이터 분석 > [SQL] 기초' 카테고리의 다른 글
[HackerRank] MySQL - Ollivander's Inventory (0) | 2025.03.23 |
---|---|
[HackerRank] MySQL - Top Competitors (0) | 2025.03.21 |
[hackerrank] MySQL - The Report (0) | 2025.03.20 |
[hackerrank] MySQL - Contest Leaderboard (0) | 2025.03.20 |
[hackerrank] MySQL - Challenges (0) | 2025.03.20 |