Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kalenjordan/11182396 to your computer and use it in GitHub Desktop.
Save kalenjordan/11182396 to your computer and use it in GitHub Desktop.
Average Sales Excluding Shipping, Tax, Discounts
SELECT
date_format(date_sub(created_at, INTERVAL 5 HOUR), "%Y-%m-%d") AS `Day`
, count(*) as `Count`
, AVG(grand_total - tax_amount - shipping_amount) AS `Avg Sales Excluding Tax/Shipping/Discounts`
, AVG(discount_amount) `Avg Discount`
, AVG(tax_amount) `Avg Tax`
, AVG(shipping_amount) `Avg Shipping`
FROM sales_flat_order
WHERE created_at BETWEEN '2014-04-01 05:00:00' AND '2014-04-30 05:00:00'
GROUP BY date_format(date_sub(created_at, INTERVAL 5 HOUR), "%Y-%m-%d")
ORDER BY date_format(date_sub(created_at, INTERVAL 5 HOUR), "%Y-%m-%d") DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment