Hi,
For the challenge Building and Organizing Complex Queries , I was able to come up with the code below.THis is different from the given solution and it worked on checking. I was hoping for some feedback on this. Thank You!
WITH total_customer_group AS
(SELECT
c.country, c.first_name|| ' '||c.last_name AS customer_name, SUM(i.total) AS total_amount
FROM customer AS c
INNER JOIN invoice as i
ON c.customer_id = i.customer_id
GROUP BY 2
)
SELECT
t.country, t.customer_name,
MAX(t.total_amount) AS total_purchased
FROM total_customer_group AS t
GROUP BY 1
ORDER BY 1,3 DESC