The Report

Sort by

recency

|

3294 Discussions

|

  • + 0 comments
    SELECT
        CASE 
            WHEN g.grade < 8 THEN NULL 
            ELSE s.name 
        END AS name,
        g.grade,
        s.marks
    FROM 
        students s
    JOIN 
        grades g
    ON 
        s.marks BETWEEN g.min_mark AND g.max_mark
    ORDER BY 
        g.grade DESC,s.name asc,s.marks asc;
    
  • + 1 comment

    select students.name , grades.grade,students.marks from students join grades on students.marks>= grades.min_mark and students.marks<= grades.max_mark and grades.grade>7 order by grades.grade desc ,students.name asc;

    select null , grades.grade,students.marks from students join grades on students.marks>= grades.min_mark and students.marks<= grades.max_mark and grades.grade<8 order by grades.grade desc ,students.marks asc

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

  • + 0 comments

    WITH student_grades AS ( SELECT Name, CASE WHEN Marks <= 100 AND Marks >= 90 THEN 10 WHEN Marks <= 89 AND Marks >= 80 THEN 9 WHEN Marks <= 79 AND Marks >= 70 THEN 8 WHEN Marks <= 69 AND Marks >= 60 THEN 7 WHEN Marks <= 59 AND Marks >= 50 THEN 6 WHEN Marks <= 49 AND Marks >= 40 THEN 5 WHEN Marks <= 39 AND Marks >= 30 THEN 4 WHEN Marks <= 29 AND Marks >= 20 THEN 3 WHEN Marks <= 19 AND Marks >= 10 THEN 2 ELSE 1 END AS Grade, Marks FROM Students ), 8nAbove AS ( SELECT CASE WHEN Grade >= 8 AND Grade <= 10 THEN Name ELSE NULL END AS Name, Grade, Marks FROM student_grades ) SELECT Name, Grade, Marks FROM 8nAbove ORDER BY Grade DESC,
    CASE WHEN Grade >= 8 AND Grade <= 10 THEN Name -- For Grade >= 8, order by Name alphabetically ELSE NULL END ASC, Marks ASC;

  • + 0 comments

    SELECT CASE WHEN G.Grade < 8 Then 'NULL' ELSE S.Name END as Names, G.Grade, S.Marks

    FROM Students as S Join Grades as G ON S.Marks between G.Min_Mark and G.Max_Mark

    ORDER BY G.Grade DESC, S.Name ASC, S.Marks DESC;