Magento 2 SQL queries › Prices and promotions
How many orders had free shipping last month?
Short answer: Orders with something to ship and a shipping amount of 0 had free shipping, whatever the reason.
In the Magento admin
- Export last month's orders with the Shipping and Handling column and count the zeros.
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 SUM(o.base_shipping_amount = 0) AS free_shipping_orders,
COUNT(*) AS all_shipped_orders,
ROUND(100 * SUM(o.base_shipping_amount = 0) / COUNT(*), 1) AS share_pct
FROM sales_order o
WHERE o.is_virtual = 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
- Free shipping can come from a cart rule, a free-shipping method or a 0 rate. Group by
shipping_methodto see which.