AI Reports

Magento 2 SQL queries › Orders and sales

Which shipping methods do customers choose most?

Short answer: The Shipping report groups by carrier title after a statistics refresh. A query on sales_order gives method codes, counts and shipping charged in one go.

In the Magento admin

  1. Refresh statistics in Reports › Statistics › Refresh Statistics.
  2. Open Reports › Sales › Shipping and pick a period.

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 o.shipping_method,
       MAX(o.shipping_description) AS example_title,
       COUNT(*) AS orders,
       ROUND(SUM(o.base_shipping_amount), 2) AS shipping_charged
FROM sales_order o
WHERE o.shipping_method IS NOT NULL
  AND o.state <> 'canceled'
  AND o.created_at >= CURRENT_DATE - INTERVAL 90 DAY
GROUP BY o.shipping_method
ORDER BY orders DESC;

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