Much briefer way of solving
SELECT
c.country,
c.first_name || " " || c.last_name customer_name,
MAX(i.total) total_purchased
FROM customer c
INNER JOIN
(
SELECT
customer_id,
SUM(total) total
FROM invoice
GROUP BY 1
) i ON i.customer_id = c.customer_id
GROUP BY 1
ORDER BY 1;