clear markdown compare help donate comments/suggestions/bugs a leap of faith? diddy dollings
clear markdown donate comments/suggestions/bugs a leap of faith?
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 400783 distinct fiddles created so far.

create table invoices (id int, order_id int, customer_id int, total int);
 hidden batch(es)


insert into invoices values (1,2,1,5580), (2,3,1,3600), (3,1,1,4900), (4,4,2,190), (5,7,3,22200);
 hidden batch(es)


select customer_id, total, rank from ( select customer_id, total, @rank := @rank + 1 as rank from ( select customer_id, sum(total) total from invoices group by customer_id order by sum(total) desc ) t1, (select @rank := 0) t2 ) t3 where customer_id = 1;
customer_id total rank
1 14080 2
 hidden batch(es)