pepperwind / answer_key /kpis /b2b_order_value.sql
rasinmuhammed's picture
Pepperwind Trading Co. preview, version 1.0
27ec678 verified
Raw History Blame Contribute Delete
378 Bytes
-- Wholesale order value, by currency
-- Totals of wholesale orders not cancelled, by the month placed.
SELECT strftime(placed_at, '%Y-%m') AS month, currency AS grp, sum(total) AS value FROM commerce.order WHERE placed_at >= TIMESTAMP '2023-10-01' AND placed_at < TIMESTAMP '2026-10-01' AND ((b2b_account_id IS NOT NULL) AND (cancelled_at IS NULL)) GROUP BY 1, 2 ORDER BY 1, 2