Hello all,
this suggested solution seems overly complicated
I am wondering if the following is correct, it might be wrong that it only works on this certain case?
with c as
(select c.country, c.first_name||" "||c.last_name AS customer_name, sum(i.total) AS total_purchased
from customer c left join invoice i
on c.customer_id = i.customer_id
group by c.country, c.customer_id
ORDER BY country)
select country, customer_name, max(total_purchased) as total_purchased
from c
group by country
ORDER by country