I\'m trying to do a query where it adds up the totals for the orders from each customer.
I have tried a few different ways but I am not sure the right way to do it.<
Sum
and count
can be used to get the result you want:
select CustomerID, count(*) as Orders, ShipName, sum(Total) as Total
from Table
group by CustomerID, ShipName
order by count(*) desc;
select CustomerID, count(OrderID) Orders, ShipName, sum(Total) Total
from Order_TAB
group by CustomerID, ShipName