I’ve written this query, which is more concise than the provided answer (it can surely be improved though)
WITH total_customer_country AS
(
SELECT c.customer_id customer_id,
c.country country,
(c.first_name || ’ ’ || c.last_name) customer_name,
SUM(total) total_purchased
FROM customer c
LEFT JOIN invoice i ON i.customer_id = c.customer_id
GROUP BY country, customer_name
)
SELECT country, customer_name, MAX(total_purchased) total_purchased
FROM total_customer_country
GROUP BY country
ORDER BY country