AI Reports

Magento 2 SQL queries › Customers

How many customers registered this month, per customer group?

Short answer: Filter the customer grid by Customer Since and group, or count customer_entity rows by group in one query.

In the Magento admin

  1. Go to Customers › All Customers › Filters.
  2. Set Customer Since from the 1st of this month and pick one Group at a time.

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 g.customer_group_code AS customer_group, COUNT(*) AS new_customers
FROM customer_entity c
JOIN customer_group g ON g.customer_group_id = c.group_id
WHERE c.created_at >= DATE_FORMAT(CURRENT_DATE, '%Y-%m-01')
GROUP BY g.customer_group_id, g.customer_group_code
ORDER BY new_customers 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