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.



Add a status_aggregate temporary table. This table should have the following columns:

  • month - selected from the status table
  • active - the SUM() of active users for this month
  • canceled - the SUM() 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.

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?