Introduction
Simple CASE WHEN
Searched CASE WHEN
CASE WHEN with aggregates
17. CASE WHEN with COUNT – practice
CASE WHEN with GROUP BY
Revision

Instruction

Okay. Let's do one more exercise in this regard.

Exercise

Count the number of candidates who scored:

  • at least 80 in maths (good_math),
  • at least 60 (average_math),
  • or less than 60 (poor_math).

Show only those candidates who have provided a preferred_contact form.

Stuck? Here's a hint!

One of the counts is as follows:

COUNT(CASE WHEN score_math >= 80 THEN id END)
AS good_math

Console

Code editor

Result

TableConsole