Introduction
Simple CASE WHEN
6. Simple CASE WHEN with NULLs
Searched CASE WHEN
CASE WHEN with aggregates
CASE WHEN with GROUP BY
Revision

Instruction

That's correct! Having gone through Part 5 about NULLs, you might want to ask: okay, but how do NULLs behave in CASE WHEN?

The answer is pretty straightforward: NULL will always go to the ELSE part if you include it. Let's check this out in an exercise.

Exercise

For table candidate, show each candidate's id, preferred_contact and the third column which will print:

  • 'traditional' if the preferred_contact is 'mail',
  • 'modern' if it's 'mobile' or 'e-mail',
  • or 'other' otherwise.
Look what is shown for NULL values.

Console

Code editor

Result

TableConsole