select c.customers_id, c.customers_firstname, c.customers_lastname, COUNT(o.customers_id) as oCount, sum(op.products_quantity * op.final_price) as ordersum from customers c, orders_products op, orders o WHERE c.customers_id = o.customers_id and o.orders_id = op.orders_id group by c.customers_firstname, c.customers_lastname order by ordersum DESC