Top customers by spend in PrestaShop
Rank PrestaShop customers by lifetime revenue from valid orders.
PrestaShop · PostgreSQL
SELECT c.id_customer,
c.firstname,
c.lastname,
c.email,
COUNT(o.id_order) AS orders,
ROUND(SUM(o.total_paid_tax_incl), 2) AS lifetime_revenue
FROM ps_customer c
JOIN ps_orders o ON o.id_customer = c.id_customer AND o.valid = 1
GROUP BY c.id_customer, c.firstname, c.lastname, c.email
ORDER BY lifetime_revenue DESC
LIMIT 20;How it works
Aggregates valid order totals per customer to reveal your highest-value buyers for VIP and loyalty targeting.
Run this on your own database
BeQuery mirrors your PrestaShop MySQL database to an isolated PostgreSQL copy, so you can run queries like this one without ever touching production.
Start free No credit card