일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- Python3
- two-pointer
- 자연어처리
- GenerativeAI
- heap
- stratascratch
- sql코테
- GenAI
- codeup
- 니트코드
- 리트코드
- 구글퀵랩
- slidingwindow
- Python
- medium
- 파이썬기초100제
- dfs
- SQL
- nlp
- 알고리즘
- 투포인터
- 파이썬알고리즘
- 생성형AI
- 코드업
- 릿코드
- gcp
- LeetCode
- 슬라이딩윈도우
- Microsoft
- 파이썬
Archives
- Today
- Total
Tech for good
[Stratascratch/SQL] Fifth Highest Salary Without TOP or LIMIT 본문
IT/Data Science
[Stratascratch/SQL] Fifth Highest Salary Without TOP or LIMIT
Diana Kang 2025. 2. 27. 10:59
select salary
from (
select
salary,
row_number() over (order by salary desc) as rnk
from worker) cte
where rnk = 5;
윈도우 함수
- ROW_NUMBER()
- 결과 집합의 파티션 내 각 행에 순차적인 정수를 할당하는 순위 함수(윈도우 함수)
- 행의 번호는 각 파티션에 대해 1번부터 할당한다.
- 정렬의 중복 값이 있어도 서로 다른 정수를 할당한다.
- 결과 집합의 파티션 내 각 행에 순차적인 정수를 할당하는 순위 함수(윈도우 함수)
# 예시
SELECT first_name,
last_name,
city,
ROW_NUMBER() OVER (
PARTITION BY city
ORDER BY first_name
) row_num
FROM sales.customers
ORDER BY city;
'IT > Data Science' 카테고리의 다른 글
[Stratascratch/SQL] Highest Paid Employee By Department (0) | 2025.02.27 |
---|---|
[Stratascratch/SQL] Top 10 Salaries (0) | 2025.02.27 |
[Stratascratch/SQL] Find the country that has the most companies listed on Forbes (0) | 2025.02.27 |
[Stratascratch/SQL] User Feature Completion (0) | 2025.02.26 |
[Stratascratch/SQL] Find the total number of approved friendship requests in January and February (0) | 2025.02.26 |