일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 코드업
- 파이썬알고리즘
- 릿코드
- medium
- Python3
- 자연어처리
- TwoPointer
- 파이썬
- 구글퀵랩
- SQL
- 알고리즘
- 머신러닝
- two-pointer
- GenAI
- Python
- stratascratch
- 생성형AI
- LeetCode
- nlp
- Blazor
- 파이썬기초
- 리트코드
- sql코테
- 투포인터
- codeup
- 파이썬기초100제
- Microsoft
- GenerativeAI
- 데이터사이언스
- gcp
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 | |
사용 | 그룹 외부에서 묶어 순위 및 그룹별 집계를 구할 떄 사용 | 그룹 내 순위 및 그룹별 집계를 구할 때 사용 |
결과값 | 특정 원하는 컬럼에 대해서 추출해 결과값 보여줌 | 전체 데이터에서 원하는 결과값 보여줌 |