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.
For both cases your order by statement is the same.. As in when grades<8 then you order by grade, then name and then marks. However the question states to order by grade, then marks, when grades<8
And in the next case it states to order by grade and then by name. I guess its due to the clarity
Here's my code:
select s.name, g.grade, s.marks from students s left join grades g on s.marks between g.min_mark and g.max_mark where g.grade>=8 order by g.grade desc, s.name asc;
select NULL, g.grade, s.marks from students s left join grades g on s.marks between g.min_mark and g.max_mark where g.grade<8 order by g.grade desc, s.marks asc;
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 →
For both cases your order by statement is the same.. As in when grades<8 then you order by grade, then name and then marks. However the question states to order by grade, then marks, when grades<8 And in the next case it states to order by grade and then by name. I guess its due to the clarity Here's my code:
select s.name, g.grade, s.marks from students s left join grades g on s.marks between g.min_mark and g.max_mark where g.grade>=8 order by g.grade desc, s.name asc;
select NULL, g.grade, s.marks from students s left join grades g on s.marks between g.min_mark and g.max_mark where g.grade<8 order by g.grade desc, s.marks asc;