Created
January 31, 2024 03:14
-
-
Save julie-mills/150cbe7ed6c524c6eb6cc3afbd2b6027 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
INSERT INTO | |
mv_daily_sales_summary | |
SELECT | |
o.tenant_id AS seller_id, | |
p.product_category, | |
o.order_date AS sale_date, | |
COUNT(*) AS total_orders, | |
SUM(o.total_amount) AS total_sales | |
FROM | |
orders o | |
JOIN products p ON o.product_id = p.product_id | |
AND o.tenant_id = p.tenant_id | |
WHERE | |
o.order_date > CURRENT_DATETIME - TIMESTAMP_MILLIS(o._last_scheduled_completion_time) | |
GROUP BY | |
seller_id, | |
p.product_category, | |
sale_date | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment