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.
- Prepare
- SQL
- Basic Join
- The Report
- Discussions
The Report
The Report
Sort by
recency
|
3294 Discussions
|
Please Login in order to post a 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
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
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;
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;