The Report — HackerRank Simple Joins

Maria 10 99
Jane 9 81
Julia 9 88
Scarlet 8 78
NULL 7 63
NULL 7 68
  • Jane (grade 9)
  • Julia (grade 9)
  • Scarlet (grade 8)
SELECT CASE 
WHEN grade >= 8 THEN NAME
ELSE NULL
END NAME,
grade,
marks
FROM (SELECT NAME,
CASE
WHEN marks BETWEEN 0 AND 9 THEN 1
WHEN marks BETWEEN 10 AND 19 THEN 2
WHEN marks BETWEEN 20 AND 29 THEN 3
WHEN marks BETWEEN 30 AND 39 THEN 4
WHEN marks BETWEEN 40 AND 49 THEN 5
WHEN marks BETWEEN 50 AND 59 THEN 6
WHEN marks BETWEEN 60 AND 69 THEN 7
WHEN marks BETWEEN 70 AND 79 THEN 8
WHEN marks BETWEEN 80 AND 89 THEN 9
WHEN marks BETWEEN 90 AND 100 THEN 10
END grade,
marks
FROM students) a
ORDER BY grade DESC,
NAME ASC

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store