-
-
Save codecademydev/beac7e2430e28a5813c19abb40f78301 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH previous_query AS ( | |
SELECT customer_id, COUNT(subscription_id) AS 'subscriptions' | |
FROM orders | |
GROUP BY customer_id) | |
SELECT customers.customer_name, previous_query.subscriptions | |
FROM previous_query | |
JOIN customers | |
ON previous_query.customer_id = customers.customer_id; | |
SELECT customers.customer_name, COUNT(orders.subscription_id) AS 'Subscriptions' | |
FROM customers | |
JOIN orders | |
ON customers.customer_id = orders.customer_id | |
GROUP BY 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment