SELECT CustomerID, 'OrderTotal' =
SUM(UnitPrice * Quantity),
'TotalFreight' = SUM(Freight)
FROM ORDERS
INNER JOIN [Order Details]
ON Orders.OrderID = [Order Details].OrderID
GROUP BY CustomerID
ORDER BY CustomerID
CustomerID OrderTotal TotalFreight
---------- ----------- -----------
ALFKI 4596.2000 419.6000
ANATR 1402.9500 306.5900
ANTON 7515.3500 667.2900
AROUT 13806.5000 1447.1400
BERGS 26968.1500 4835.1800
Listing 1 You can use the SUM function in a GROUP BY clause to get totals for each customer. Like all aggregate functions, SUM isn't powerful in and of itself, but you can combine it with other functions to powerful effect.