Magento 2 SQL queries › Customers
How many customer accounts have never placed an order?
Short answer: The customer grid can't filter by orders. Check each account against sales_order with NOT EXISTS.
In the Magento admin
- There's no admin filter for this. Export customers and orders and match them in a spreadsheet.
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 customers_without_orders
FROM customer_entity c
WHERE NOT EXISTS (SELECT 1 FROM sales_order o WHERE o.customer_id = c.entity_id);
To list them, newest first:
SELECT c.entity_id, c.email, c.created_at, c.website_id
FROM customer_entity c
WHERE NOT EXISTS (SELECT 1 FROM sales_order o WHERE o.customer_id = c.entity_id)
ORDER BY c.created_at DESC
LIMIT 100;
Good to know
- Accounts that only ever ordered as guests (before registering) also show here, because guest orders aren't linked to the account.