AIHelperBot
Loading...
Open main menu
SQL Generator
Pricing
Posts
Snippet
get the 10 customers with the most payments
Copy
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
;
dvdrental
public