You are viewing a single comment's thread. Return to all comments →
Hello @kaikumar30, let me reframe that above query for you:
SELECT (CASE g.grade>=8 WHEN TRUE THEN s.name ELSE null END),g.grade,s.marks FROM students s INNER JOIN grades g ON s.marks BETWEEN min_mark AND max_mark ORDER BY g.grade DESC,s.name,s.marks;
In MySql, CASE statement acts like a "if" condition, so if the expression after CASE statement matches the boolean value after WHEN clause, it executes the result after THEN clause; otherwise it will execute result after ELSE clause.