Only this week, get the SQL Complete Track of 9 courses in a special prize of $330$89!
Introduction
Simple CASE WHEN
Searched CASE WHEN
CASE WHEN with aggregates
CASE WHEN with GROUP BY
20. CASE WHEN with GROUP BY – practice
Summary

Instruction

Excellent! Let's do one more exercise of this kind.

Exercise

For each candidate, with at least one application, show their id and three more columns called count_accepted, count_rejected, count_pending. Each of these columns should count the number of courses for which the candidate has been accepted, rejected or where the decision is pending.

Sort the rows in the ASCending order by the id.

Stuck? Here's a hint!

The first SUM will look like this:

SUM(CASE WHEN status = 'accepted' THEN 1 ELSE 0 END) AS count_accepted