Chapter 4 Exercise 13

13. Who is the best customer in terms of total purchase value? (4)

SELECT Customers.CustomerID, Customers.LastName, Sum(Sales.Amount) AS SumOfAmount
FROM Customers INNER JOIN Sales ON Customers.CustomerID = Sales.CustomerID
GROUP BY Customers.CustomerID, Customers.LastName
ORDER BY Sum(Sales.Amount) DESC;