Magento 2 SQL queries › Prices and promotions
How much discount did we give in total last month?
Short answer: Each order stores its total discount. Sum it for last month, leaving out canceled orders.
In the Magento admin
- Refresh statistics and open Reports › Sales › Orders; the Discount column shows the total.
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 COUNT(*) AS orders_with_discount,
ROUND(-SUM(o.base_discount_amount), 2) AS total_discount
FROM sales_order o
WHERE o.base_discount_amount < 0
AND o.state <> 'canceled'
AND o.created_at >= DATE_FORMAT(CURRENT_DATE - INTERVAL 1 MONTH, '%Y-%m-01')
AND o.created_at < DATE_FORMAT(CURRENT_DATE, '%Y-%m-01');
Good to know
- Catalog price rules and special prices lower the product price itself, so they don't appear as a discount here.