일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- two-pointer
- 파이썬기초100제
- 생성형AI
- sql코테
- 리트코드
- 머신러닝
- 구글퀵랩
- TwoPointer
- LeetCode
- 릿코드
- 파이썬기초
- GenAI
- nlp
- GenerativeAI
- 파이썬
- 자연어처리
- 파이썬알고리즘
- gcp
- 알고리즘
- 데이터사이언스
- Python3
- 코드업
- 투포인터
- SQL
- codeup
- stratascratch
- Microsoft
- Python
- Blazor
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:59select 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 |