33. Assign Letter Grades (Band Join)
MediumJoinsnon-equi joinBETWEENrange lookup
Not every join matches on equality. A non-equi join pairs rows on a range — here, each numeric score falls into exactly one grade band.
Task: join each student's score to the grade band that contains it, where a band matches when score BETWEEN lo AND hi. Return the student, their score, and the letter grade.
Output columns, in this exact order: student, score, grade. Order by score descending, breaking ties by student ascending.
Tables
Loading schema…
Expected outputrows must come back in this order
Computing expected output…
This is the result for the example data above. On Submit your query is graded against this example plus 4 hidden edge cases — 5test cases in all. A sloppy query that only fits the example won't pass.
SQL· SQLite · runs in your browser
⌘/Ctrl+↵ run · ⇧⌘/Ctrl+↵ submit
Run a query to see its output here.