Last active
October 21, 2020 01:49
-
-
Save antoine-lizee/bdff5285b345bc04ad6d6ed131cb20be to your computer and use it in GitHub Desktop.
This file contains hidden or 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 orders from senior customers per month: | |
WITH senior_customers AS ( -- [This would not be a pb if PG 12+] | |
SELECT * | |
FROM remote.customers | |
WHERE age > 60 | |
) | |
SELECT date_trunc(paid_date) AS order_month, count(*) AS n_orders | |
FROM remote.orders o -- brings back to the local server ALL the orders | |
JOIN senior_customers c ON c.id = o.customer_id -- do a JOIN without the indices from the remote |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment