AI Reports

Magento 2 SQL queries › Orders and sales

What's our average order value per month this year?

Short answer: Magento's Sales report shows totals and order counts per period; divide one by the other. Or run one query that returns AOV for every month this year.

In the Magento admin

  1. Refresh the Orders statistics in Reports › Statistics.
  2. Open Reports › Sales › Orders, set Period to Month and the dates to this year.
  3. Divide Sales Total by Orders for each row.

With one query

These queries only read data. Run them on a copy of your database if you can, or ask your developer to. If your tables have a prefix (set in app/etc/env.php), add it to each table name.

Works on Magento Open Source and Adobe Commerce:

SELECT DATE_FORMAT(o.created_at, '%Y-%m') AS month,
       COUNT(*) AS orders,
       ROUND(AVG(o.base_grand_total), 2) AS avg_order_value
FROM sales_order o
WHERE o.state <> 'canceled'
  AND o.created_at >= DATE_FORMAT(CURRENT_DATE, '%Y-01-01')
GROUP BY month
ORDER BY month;

Good to know

Related

Gaurav Harsh

Gaurav Harsh is a Magento developer who works on large Adobe Commerce stores and builds AI Reports, a Magento extension for asking your store's data questions in plain English. LinkedIn