Learn
Calculating Churn
Multiple Month: Sum Active and Canceled Users
Now that we have an active and canceled status for each subscription for each month, we can aggregate them.
We will GROUP BY
month and create a SUM()
of the two columns from the status
table, is_active
and is_canceled
.
This provides a list of months, with their corresponding number of active users at the beginning of the month and the number of those users who cancel during the month.
Instructions
1.
Add a status_aggregate
temporary table. This table should have the following columns:
month
- selected from thestatus
tableactive
- theSUM()
of active users for this monthcanceled
- theSUM()
of canceled users for this month
We’ve added:
SELECT * FROM status_aggregate;
at the bottom of this exercise so you can visualize the temporary table you create.