Last active
May 13, 2024 00:06
-
-
Save lfy79001/6a711aff78e33ff6d06315afe792b168 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
SELECT | |
DATE(order_purchase_timestamp) AS date, | |
-- Days since 2017-01-01 | |
CAST(JULIANDAY(order_purchase_timestamp) - JULIANDAY('2017-01-01') AS INTEGER) AS day, | |
product_category_name_english AS category, | |
SUM(price) AS sales | |
FROM | |
orders | |
JOIN order_items USING (order_id) | |
JOIN products USING (product_id) | |
JOIN product_category_name_translation USING (product_category_name) | |
WHERE | |
order_purchase_timestamp BETWEEN '2017-01-01' AND '2018-08-29' | |
AND category IN ('health_beauty', 'auto', 'toys', 'electronics', 'fashion_shoes') | |
GROUP BY | |
day, | |
product_category_name_english |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment