Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Simple CASE WHEN
Searched CASE WHEN
CASE WHEN with aggregates
15. CASE WHEN with SUM continued
CASE WHEN with GROUP BY
Summary

Instruction

Great! The use of CASE WHEN together with SUM is actually so important that we should do one more exercise here. Are you ready?

Exercise

Count the number of candidates with preferred_contact set to:

  • 'mobile' (mobile_sum).
  • 'e-mail' (email_sum).
  • 'mail' (mail_sum).
  • with NULL (null_sum).

Only count candidates whose score in math and score in language are both greater than or equal to 30.

Stuck? Here's a hint!

Start with:

SELECT
  SUM(CASE WHEN preferred_contact = 'mobile' THEN 1 ELSE 0 END) AS mobile_sum

and continue the same way.