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.
WITH X AS (SELECT st.id, st.name,st.marks,gr.grade
FROM STUDENTS st
LEFT JOIN GRADES gr on st.marks >= gr.min_mark and st.marks<=max_mark)
SELECT NAME, GRADE, MARKS FROM (SELECT (CASE WHEN grade > 7 THEN NAME ELSE 'NULL' END) AS NAME, GRADE, MARKS
FROM X ) xyz
ORDER BY GRADE DESC, NAME ASC, 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 →
WITH X AS (SELECT st.id, st.name,st.marks,gr.grade FROM STUDENTS st LEFT JOIN GRADES gr on st.marks >= gr.min_mark and st.marks<=max_mark)
SELECT NAME, GRADE, MARKS FROM (SELECT (CASE WHEN grade > 7 THEN NAME ELSE 'NULL' END) AS NAME, GRADE, MARKS FROM X ) xyz ORDER BY GRADE DESC, NAME ASC, MARKS ASC