SELECT customers.*, top_10.total FROM (SELECT customer_id, SUM(top_amount) AS total FROM purchases GROUP BY customer_id LIMIT 0, 10) AS top_10, customers ORDER BY top_10.total DESC