Last active
August 29, 2015 14:14
-
-
Save thegorgon/86c662d15bfbd893f16d to your computer and use it in GitHub Desktop.
Query for Superbowl Offer Volume by Region
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
SELECT | |
service_regions.name region_name, | |
SUM(cart_items.quantity) total_quantity, | |
offers.name offer_name | |
FROM | |
orders | |
INNER JOIN cart_items ON cart_items.order_id = orders.id | |
INNER JOIN offers ON offers.id = cart_items.offer_id | |
INNER JOIN service_regions ON service_regions.id = orders.service_region_id | |
WHERE | |
DATE(orders.delivery_window_starts_at - INTERVAL '7' HOUR) = '2015-02-01' | |
GROUP BY | |
service_regions.name, | |
offers.name | |
ORDER BY region_name ASC, total_quantity DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this must be run against the production follower db