일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 슬라이딩윈도우
- GenAI
- Blazor
- two-pointer
- 파이썬
- 리트코드
- 코드업
- Python
- medium
- gcp
- SQL
- nlp
- 자연어처리
- 릿코드
- Python3
- codeup
- sql코테
- Microsoft
- slidingwindow
- 구글퀵랩
- 생성형AI
- LeetCode
- stratascratch
- 파이썬알고리즘
- 니트코드
- dfs
- GenerativeAI
- 파이썬기초100제
- 투포인터
- 알고리즘
Archives
- Today
- Total
Tech for good
[Stratascratch/SQL] Highest Paid Employee By Department 본문
IT/Data Science
[Stratascratch/SQL] Highest Paid Employee By Department
Diana Kang 2025. 2. 27. 06:11https://platform.stratascratch.com/coding/9854-find-the-5-highest-salaries?code_type=3


# 풀이1
select department, worker_id, salary
from (select *, rank() over(partition by department order by salary desc) as rnk
from worker) as cte
where rnk = 1;
# 풀이2
select worker_id, department, salary
from(
select *, max(salary) over(partition by department) as max_dep
from worker) as cte
where salary = max_dep
partition by란?
(참고: https://project-notwork.tistory.com/53)
GROUP BY | PARTITION BY | |
사용 | 그룹 외부에서 묶어 순위 및 그룹별 집계를 구할 떄 사용 | 그룹 내 순위 및 그룹별 집계를 구할 때 사용 |
결과값 | 특정 원하는 컬럼에 대해서 추출해 결과값 보여줌 | 전체 데이터에서 원하는 결과값 보여줌 |