I'm trying to solve the "Customer's orders Challenge" from KhanAcademy, not in the platform but in SQL Management Studio. And I haven't obtain the same result as on the platform.
This is the challenge: "Step 2 Now, create another query that will result in one row per each customer, with their name, email, and total amount of money they've spent on orders. Sort the rows according to the total money spent, from the most spent to the least spent."
This is my code and the error that appears when I try to run it in SQL Server.
"Column 'Customers.Name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."
I really need a hand on this.
SELECT Customers.Name, Customers.email, SUM(Orders.Price) AS 'Total Orders'
FROM Customers
LEFT OUTER JOIN Orders
ON Customers.ID = Orders.CustomerID
GROUP BY Customers.ID
ORDER BY Orders.Price DESC