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.
CREATE VIEW Students_View AS
SELECT Name,
(
SELECT Grade FROM Grades WHERE Min_Mark <= Students.Marks AND Students.Marks <= Max_Mark
) AS Grade, Marks
FROM Students;
SELECT
CASE
WHEN Grade >= 8
THEN Name
END,
Grade,
Marks
FROM Students_View
ORDER BY Grade DESC, 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 →
My solution by creating a view table.
CREATE VIEW Students_View AS SELECT Name, ( SELECT Grade FROM Grades WHERE Min_Mark <= Students.Marks AND Students.Marks <= Max_Mark ) AS Grade, Marks FROM Students;
SELECT CASE WHEN Grade >= 8 THEN Name END, Grade, Marks FROM Students_View ORDER BY Grade DESC, Name ASC;