AI Reports

Magento 2 SQL queries › Customers

How many customers placed more than one order this year?

Short answer: There's no repeat-customer report in Magento. Group this year's orders by email and count the emails with two or more orders.

In the Magento admin

  1. Export this year's orders from Sales › Orders to CSV.
  2. In a spreadsheet, count how many emails appear more than once.

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 repeat_customers
FROM (
  SELECT o.customer_email
  FROM sales_order o
  WHERE o.state <> 'canceled'
    AND o.created_at >= DATE_FORMAT(CURRENT_DATE, '%Y-01-01')
  GROUP BY o.customer_email
  HAVING COUNT(*) > 1
) r;

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