AI Reports

Guides › Customers

How to find Magento customers who haven't ordered in 6 months

Short answer: Magento has no built-in report for this. You can match a customer export against an order export in a spreadsheet, or run one query that lists each registered customer's last order date.

In the admin: two exports and a spreadsheet

  1. Export your customers: System › Data Transfer › Export, Entity Type Customers Main File.
  2. Export your orders: Sales › Orders, then Export › CSV at the top of the grid.
  3. In a spreadsheet, find each customer's latest order date by email address and filter for dates more than 6 months ago.

It works for a small store; with thousands of orders it gets slow.

With one query

Registered customers whose last order (not canceled) is more than 6 months old, newest first. Guest orders aren't linked to a customer account, so they're not included. The same query works on Open Source and Adobe Commerce.

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.

SELECT
  c.entity_id          AS customer_id,
  c.email,
  c.firstname,
  c.lastname,
  COUNT(o.entity_id)   AS orders,
  MAX(o.created_at)    AS last_order
FROM customer_entity c
JOIN sales_order o ON o.customer_id = c.entity_id AND o.state <> 'canceled'
GROUP BY c.entity_id, c.email, c.firstname, c.lastname
HAVING MAX(o.created_at) < NOW() - INTERVAL 6 MONTH
ORDER BY last_order DESC;

Customers who never ordered

SELECT c.entity_id AS customer_id, c.email, c.firstname, c.lastname, c.created_at AS registered
FROM customer_entity c
LEFT JOIN sales_order o ON o.customer_id = c.entity_id AND o.state <> 'canceled'
WHERE o.entity_id IS NULL
ORDER BY c.created_at DESC;

Only customers who agreed to marketing emails

Before you email anyone about a win-back offer, check they agreed to it. In the UK and EU that's the law. This version keeps only customers who are subscribed to your newsletter:

SELECT
  c.entity_id          AS customer_id,
  c.email,
  c.firstname,
  c.lastname,
  COUNT(o.entity_id)   AS orders,
  MAX(o.created_at)    AS last_order
FROM customer_entity c
JOIN sales_order o ON o.customer_id = c.entity_id AND o.state <> 'canceled'
JOIN newsletter_subscriber ns ON ns.customer_id = c.entity_id AND ns.subscriber_status = 1   -- 1 = subscribed
GROUP BY c.entity_id, c.email, c.firstname, c.lastname
HAVING MAX(o.created_at) < NOW() - INTERVAL 6 MONTH
ORDER BY last_order DESC;

More guides

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