leetcode

Leetcode submissions
git clone git://git.laack.co/leetcode.git
Log | Files | Refs | README

rank-scores.sql (309B)


      1 --Given a table with scores return the scores
      2 --in rank order where 1 is the highest and the lowest
      3 --is n - r where r is the number of repeated values.
      4 
      5 SELECT
      6     Scores.score,
      7     (SELECT COUNT(DISTINCT score) FROM Scores s2 WHERE s2.score >= Scores.score) AS 'rank'
      8 FROM Scores
      9 ORDER BY Scores.score desc