DDSA Solutions

178. Rank Scores

Advertisement

About this solution

Rank Scores is a unknown-difficulty LeetCode problem covering the Database pattern. The MySQL solution below uses an idiomatic approach that is clean, readable, and directly submittable on LeetCode. Study the logic carefully — recognising the underlying pattern is the key skill that transfers to similar problems in interviews.

Key Techniques

178.sql
MySQL
SELECT
  score,
  DENSE_RANK() OVER(ORDER BY score DESC) AS rank
FROM Scores
ORDER BY score desc;
Advertisement
Was this solution helpful?