The Report

  • + 0 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