Last active
October 21, 2020 01:45
-
-
Save antoine-lizee/bea320f859402c3e580369f9c1316981 to your computer and use it in GitHub Desktop.
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
-- Show the distribution of customers per number of orders in 2020: | |
WITH n_orders_by_customer AS ( | |
SELECT customer_id, count(*) AS n_orders | |
FROM orders | |
WHERE paid_date > '2020-01-01' | |
GROUP BY 1 | |
) | |
SELECT n_orders, count(*) AS n_customers | |
FROM n_orders_by_customer | |
GROUP BY 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment