Magento 2 SQL queries › Prices and promotions
How many times has each coupon code been used?
Short answer: Each code's usage counter is in salesrule_coupon, including auto-generated codes that the rule grid doesn't list.
In the Magento admin
- Open the rule in Marketing › Cart Price Rules; auto-generated codes and their usage are under Manage Coupon Codes.
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.
Magento Open Source
SELECT c.code, r.name AS rule_name, c.times_used, c.usage_limit, c.expiration_date
FROM salesrule_coupon c
JOIN salesrule r ON r.rule_id = c.rule_id
ORDER BY c.times_used DESC
LIMIT 100;
Adobe Commerce
Product, category, rule and CMS values are stored per version and joined on row_id (why):
SELECT c.code, r.name AS rule_name, c.times_used, c.usage_limit, c.expiration_date
FROM salesrule_coupon c
JOIN salesrule r ON r.rule_id = c.rule_id
AND r.created_in <= UNIX_TIMESTAMP() AND r.updated_in > UNIX_TIMESTAMP()
ORDER BY c.times_used DESC
LIMIT 100;
Good to know
times_usedgoes up when an order is placed and can go down when it's canceled, depending on your Magento version and settings.