DIV2RANKLIST - Editorial

PROBLEM LINK:

Practice
Contest:

DIFFICULTY:

TBD

PREREQUISITES:

Basic SQL

PROBLEM:

Your task is to output the Div-2 ranklist. That is, list the usernames of the Div-2 participants, in decreasing order of their score.

A participant is in Div-2 if their rating is >= 1600, and < 2000.

EXPLANATION:

We can use WHERE to filter only those rows where the rating is in the correct Div-2 range. Then, we can use ORDER BY to sort these rows in descending order based on their scores, and finally output those usernames.

And remember to have the column alias set correctly.

Code
SELECT username AS 'Div 2 Ranklist'
FROM Results
WHERE (rating >= 1600) AND (rating < 2000)
ORDER BY score DESC;