문제
Write a solution to find the rank of the scores. The ranking should be calculated according to the following rules:
- The scores should be ranked from the highest to the lowest.
- If there is a tie between two scores, both should have the same ranking.
- After a tie, the next ranking number should be the next consecutive integer value. In other words, there should be no holes between ranks.
Return the result table ordered by score in descending order.

위와 같은 결과가 나오도록 쿼리를 짜면 된다.
쿼리
SELECT
score,
DENSE_RANK() OVER (ORDER BY score DESC) AS `rank`
FROM
scores;
간단한 rank 함수 사용 문제였다.
문제 출처
https://leetcode.com/problems/rank-scores/
'Study > SQL' 카테고리의 다른 글
| [LeetCode] 182. Duplicate Emails (0) | 2025.11.25 |
|---|---|
| [LeetCode] 180. Consecutive Numbers (0) | 2025.11.19 |
| [LeetCode] 177. Nth Highest Salary (0) | 2025.11.10 |
| [LeetCode] 176. Second Highest Salary (0) | 2025.11.06 |
| [Programmers] SELECT(1) (1) | 2024.08.30 |