get the 10 customers with the most payments
SELECT c.customer_id, c.first_name, c.last_name, COUNT(p.payment_id) AS num_payments
FROM customer_list cl
INNER JOIN customer c ON cl.id = c.customer_id
INNER JOIN payment p ON c.customer_id = p.customer_id
GROUP BY c.customer_id, c.first_name, c.last_name
ORDER BY num_payments DESC
LIMIT 10;
- Public
- ·
- Thu, 02 Mar 2023 18:48:15 GMT