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
|
3338 Discussions
|
Please Login in order to post a comment
SELECT IF(grade<8,NULL,name), grade, s.marks FROM students AS s JOIN Grades AS g WHERE s.marks BETWEEN g.Min_Mark AND g.Max_Mark ORDER BY grade DESC, name ASC;
with cte and union
with markwise_grade as( SELECT s.id,s.name,s.marks,g.grade from students s inner join grades g on s.marks>=min_mark and s.marks<=max_mark ), top_grade as( select markwise_grade.name as name,markwise_grade.grade,markwise_grade.marks from markwise_grade where markwise_grade.grade>=8 ), low_grade as( select "NULL" as name,markwise_grade.grade,markwise_grade.marks from markwise_grade where markwise_grade.grade<8) select * from top_grade union all select * from low_grade order by grade desc,name,marks
select case when s.marks > 69 then s.name else null end as name_edited, g.grade, s.marks from students as s left join grades as g on s.marks between g.min_mark and g.max_mark order by g.grade desc, s.name, s.marks ;