Rank Versus Dense Rank
easyQuestion 51Show how the two ranking functions differ on tied grade point averages. For every student with a known gpa, return first_name, last_name, gpa, rnk (RANK() by gpa descending) and dense (DENSE_RANK() by gpa descending). Sort by gpa descending, then id. After the two students at 3.80, RANK() skips to 6 while DENSE_RANK() continues with 5.
Expected result
+------------+-----------+------+-----+-------+ | first_name | last_name | gpa | rnk | dense | +------------+-----------+------+-----+-------+ | Evelyn | Park | 3.98 | 1 | 1 | | Sophia | Rossi | 3.92 | 2 | 2 | | Grace | Lee | 3.88 | 3 | 3 | | Ava | Patel | 3.8 | 4 | 4 | | Mia | Haddad | 3.8 | 4 | 4 | | Emily | Zhang | 3.72 | 6 | 5 | | Charlotte | Dubois | 3.67 | 7 | 6 | | Scarlett | Johnson | 3.6 | 8 | 7 | | Harper | Singh | 3.55 | 9 | 8 | | Zoe | Campbell | 3.5 | 10 | 9 | +------------+-----------+------+-----+-------+ (showing 10 of 27 rows)
Hints3 available
Sign in to use hintsTopics
Window Functions
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (sel, ins, desc)
Results
Run your SQL to see every statement's output here, then how it compares with the expected answer.
Not sure what is in a table? SHOW TABLES lists them and DESCRIBE students shows the columns, or open the database browser under the question.