Churn code not working properly

https://www.codecademy.com/programs/ff4a1f518fc0a2102b06265b0b9bd79f/content-items/2a8080024264af1e01c8fd6138aa0619/exercises/single-month-i

I’m not understanding the relevant difference between these two queries:

  1. My answer to the question:

SELECT 1.0 *
(
SELECT COUNT()
FROM subscriptions
WHERE subscription_start < ‘2017-1-01’
AND (
subscription_end
BETWEEN ‘2017-1-01’
AND ‘2017-1-31’
)
) / (
SELECT COUNT(
)
FROM subscriptions
WHERE subscription_start < ‘2017-1-01’
AND (
(subscription_end >= ‘2017-1-01’)
OR (subscription_end IS NULL)
)
)
AS result;

  1. The given solution:

SELECT 1.0 *
(
SELECT COUNT()
FROM subscriptions
WHERE subscription_start < ‘2017-01-01’
AND (
subscription_end
BETWEEN ‘2017-01-01’
AND ‘2017-01-31’
)
) / (
SELECT COUNT(
)
FROM subscriptions
WHERE subscription_start < ‘2017-01-01’
AND (
(subscription_end >= ‘2017-01-01’)
OR (subscription_end IS NULL)
)
)
AS result;

Thanks

1 Like

Hey, I’m new to SQL, so may be wrong, but I think you need to put January as ‘2017-01-%’ rather than ‘2017-1-%’ in the 1st query.