https://www.hackerrank.com/challenges/occupations/problem?isFullScreen=true
Occupations | HackerRank
Pivot the Occupation column so the Name of each person in OCCUPATIONS is displayed underneath their respective Occupation.
www.hackerrank.com
1
2
3
4
5
6
7
8
9
10
|
select
min(case when occupation = 'Doctor' then name end) 'Doctor',
min(case when occupation = 'Professor' then name end) 'Professor',
min(case when occupation = 'Singer' then name end) 'Singer',
min(case when occupation = 'Actor' then name end) 'Actor'
from (
select *, row_number() over (partition by occupation order by name) rn
from occupations
) t
group by rn
|
cs |
반응형
'SQL' 카테고리의 다른 글
leetcode 1683. Invalid Tweets (0) | 2023.04.06 |
---|---|
leetcode 1393. Capital Gain/Loss (0) | 2023.01.26 |
leetcode 1050. Actors and Directors Who Cooperated At Least Three Times (0) | 2022.07.26 |
leetcode 1084. Sales Analysis III (0) | 2022.07.18 |
leetcode 607. Sales Person (0) | 2022.07.18 |
댓글