Introduction
Simple CASE WHEN
Searched CASE WHEN
12. Searched CASE WHEN – additional practice
CASE WHEN with aggregates
CASE WHEN with GROUP BY
Revision

Instruction

Ok, let's do a more sophisticated example of CASE WHEN.

Exercise

The courses have different requirements, so let's check who can actually become a student of Ethical Hacking (id = 3). Show the name of this course, the first and last name of the candidate and another column called qualification. The rules are as follows:

  • if the student got above 80 in math, show 'qualified'.
  • If the score in math is above 70, but the score in language is above 50, show 'qualified' as well.
  • If the score in math is between 50 and 70, show 'possible'.
  • Otherwise, show 'rejected'.

Stuck? Here's a hint!

Join three tables, pick the id course 3 in the WHERE clause and include a CASE WHEN statement.

Console

Code editor

Result

TableConsole