Issue with the User Churn Project in the Data Analysis with SQL path

Hi all,
I’ve been trying to debug this for a while now. I watched the video and made some slight edits but none of them seemed to solve the larger issue at hand. My code is as follows
with months as

(select
  '2017-01-01' as first_day,
  '2017-01-31' as last_day
union
select
  '2017-02-01' as first_day,
  '2017-02-28' as last_day
union
select
  '2017-03-01' as first_day,
  '2017-03-31' as last_day
),
cross_join as
(select subscriptions.*,
  months.*
from subscriptions
cross join months
)
status as
(select
  id,
  first_day as month,
  case
    when (subscription_start < first_day)
      and (
          subscription_end > first_day
        or subscription_end is nulL)
      and (segment = 87)
     then 1
  else 0
  end as is_active_87,
  case
    when(subscription_start < first_day)
      and (
          subscription_end > first_day
          or subscription_end is null)
        and (segment = 30)
      then 1
    else 0
    end as is_active_30,
  case
    when (subscription_end between first_day and last_day) and (segment = 87)
    then 1
  else 0
  end as is_canceled_87,
  case
    when (subcription_end between first_day and last_day) and (segment = 30)
    then 1
  else 0
  end as is_canceled_30
from cross_join
)
status_aggregate as 
(select
  sum(is_active_87) as sum_active_87,
  sum(is_active_30) as sum_active_30,
  sum(is_canceled_87) as sum_canceled_87,
  sum(is_canceled_30) as sum_canceled_30
  from status
  group by month
)
select 
1.0 * sum_canceled_87 / sum_active_87 as 87_churn_rate,
1.0 * sum_canceled_30 / sum_active_30 as 30_churn_rate
from status_aggregate;

I ended up debugging it myself. The problem was not my cross join statement, it was my final case statement. I’ve been trying to figure out why for about a day now, but in the end, all I needed to rewrite was that final case statement.

Thank you for the help though!