Similar to my last post, but digging a little deeper. My next task with this report is to give a list of Top 10 Customers per location - example: Top 10 Customers at 00468, 00469, 00471, etc.
select top 10 T1.LocationID, T1.CustName, T1.Quantity--, t1.Salesperson
from
(
select
SUM(Tkscale.Qty)Quantity,
Slcust.Name CustName,
Slperson.Name Salesperson,
Inlocat.LocationID LocationID,
Inlocat.Description Location
from
Tkscale
left outer join Slcust on Tkscale.CustomerID = Slcust.CustomerID
left outer join Slperson on slcust.SalespersonID = Slperson.SalespersonID
left outer join Inlocat on Inlocat.LocationID = Tkscale.LocationID
where
slperson.Name like 'Tammy%'
group by
Inlocat.LocationID, inlocat.description, Tkscale.CustomerID, Slcust.Name, Slperson.Name
) T1
order by T1.Quantity desc, T1.LocationID, T1.CustName
output: