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.
i ran this in sql server and got the same result except my marks are also descending. so, desending by grade and mark and name is null when grade is less than 8. but yours was accepted and mine fails...not sure why.
select s.Name, g.Grade, s.Marks
from Students s
inner join Grades g
on s.Marks between g.Min_Mark and g.Max_Mark
where g.Grade >7
union all
select case when g.grade<8 then Null else s.Name end as Name, g.Grade, s.Marks
from Students s
inner 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
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 →
i ran this in sql server and got the same result except my marks are also descending. so, desending by grade and mark and name is null when grade is less than 8. but yours was accepted and mine fails...not sure why.
select s.Name, g.Grade, s.Marks from Students s inner join Grades g on s.Marks between g.Min_Mark and g.Max_Mark where g.Grade >7
union all
select case when g.grade<8 then Null else s.Name end as Name, g.Grade, s.Marks from Students s inner 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