π₯ PS(Problem Solving) π₯/SQL
[SQL] Leetcode | 178. Rank Scores
dar0m!
2021. 7. 8. 22:31
178. Rank Scores
Medium
Rank Scores - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
μμ ν¨μ DENSE_RANK()
select score, `rank`
from (
select score, DENSE_RANK() over (order by Score desc) as `rank`
from Scores
) score_rank
order by `rank`;
- 176 Second Highest Salary λ₯Ό νκ³ λλ μ½κ² ν μ μλ λ¬Έμ μλ€.
- κ·Έλ¦¬κ³ μ΄ λ¬Έμ μμλ μΉμ νκ²λ μμ½μ΄λ₯Ό νμΆνλ €λ©΄ μ΄νΌμ€νΈλ‘νΌ(`)λ₯Ό μ¬μ©νλΌλ νλ μ€λ€.
- Important Note: For MySQL solutions, to escape reserved words used as column names, you can use an apostrophe before and after the keyword. For example
Rank
.