Magento 2 SQL queries › Store setup
Which customer groups exist, and how many customers are in each?
Short answer: Customers › Customer Groups lists the groups; the query adds how many customers each has.
In the Magento admin
- Go to Customers › All Customers and filter by Group, one 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_id, g.customer_group_code, COUNT(c.entity_id) AS customers
FROM customer_group g
LEFT JOIN customer_entity c ON c.group_id = g.customer_group_id
GROUP BY g.customer_group_id, g.customer_group_code
ORDER BY g.customer_group_id;
Good to know
- Group 0, NOT LOGGED IN, never has customer accounts; it's used for guests.