We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Your ordering is not correct; if you look at your null values, it's sorting a grade of 3 before grades of 4, 6, and 7. Your order by clause doesn't makes sense and needs to be changed to this:
select
case when g.grade > 7 then s.name else NULL end,
g.grade,
s.marks
from students s
inner join grades g
on s.marks between g.min_mark and g.max_mark
order by g.grade desc, s.name asc;
Don't overcomplicate.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
The Report
You are viewing a single comment's thread. Return to all comments →
Your ordering is not correct; if you look at your null values, it's sorting a grade of 3 before grades of 4, 6, and 7. Your order by clause doesn't makes sense and needs to be changed to this:
Don't overcomplicate.