commit 1baf62c0c3ceadbf511a3eb3e320612d853e4f4b parent 42cde14c110d14f86d9e5a94034c10ff4d990485 Author: AndrewLockVI <andrewlaack1@gmail.com> Date: Mon, 21 Aug 2023 21:37:13 -0500 Completed rank scores Diffstat:
| A | rank-scores/rank-scores.sql | | | 9 | +++++++++ |
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/rank-scores/rank-scores.sql b/rank-scores/rank-scores.sql @@ -0,0 +1,9 @@ +--Given a table with scores return the scores +--in rank order where 1 is the highest and the lowest +--is n - r where r is the number of repeated values. + +SELECT + Scores.score, + (SELECT COUNT(DISTINCT score) FROM Scores s2 WHERE s2.score >= Scores.score) AS 'rank' +FROM Scores +ORDER BY Scores.score desc