I wonder if this is correct for 8. Challenge: Each Country's Best Customer

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

Hello, welcome to the community! :hatching_chick: Iā€™d like to help you with this but I cannot remember which mission this is from, can you please share the link?

1 Like

hey @tatsonreload2016

your query matches query in this post, with the difference of Left Join for you and Inner Join for the other student.

kindly follow this guideline for the community to help solve questions more efficiently.

Introducing guidelines for all technical questions in our Community

2 Likes