Last active
October 21, 2020 01:47
-
-
Save antoine-lizee/557fd78302953019c489bdeeacd0fbfd 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 number of paid and delivered orders per country: | |
WITH orders_from_france AS ( | |
SELECT paid_date, delivered_date | |
FROM orders | |
WHERE geo_country(lat, lon) = 'France' | |
) | |
, orders_by_paid_date AS ( | |
SELECT paid_date AS date_, count(*) AS n_paid_orders | |
FROM orders_from_france | |
) | |
, orders_by_delivered_date AS ( | |
SELECT delivery_date AS date_, count(*) AS n_delivered_orders | |
FROM orders_from_france | |
) | |
SELECT * | |
FROM orders_by_paid_date | |
JOIN orders_by_delivered_date USING (date_) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment