Michael,
Since I didn't have the same tables as you did, I created something similar
in terms of tables and queries that might be of help. The query that I came
up with that gave me the answer was:
SELECT TOP 5 [FirstName]+" "+[LastName] AS Salesmen, Sum(Sales.OrderAmount)
AS [Sum of Orders]
FROM Salesmen INNER JOIN Sales ON Salesmen.SalesmenIdentifier =
Sales.SalesmenIdentifier
GROUP BY [FirstName]+" "+[LastName]
ORDER BY Sum(Sales.OrderAmount) DESC;
Nothing really special going on here. There is a foreign key in the Orders
table that links back to the Salesmen table. All the query displays is a
concatonation of the First and Last Name of the salesperson and the total of
all their sales.
When I query ALL of the results I get:
Salesmen Sum of Orders
Bill Gates $465.00
Bob Maluga $85.00
John Doe $61.00
Trevor Johnson $40.59
Suzy Smith $38.55
Chris Evans $26.00
Sam Mathers $19.00
When I query the TOP 4 results I get:
Salesmen Sum of Orders
Bill Gates $465.00
Bob Maluga $85.00
John Doe $61.00
Trevor Johnson $40.59
Suzy Smith $38.55
I noticed that you are not totalling the sum of all of the orders... was
that intentional?
HTH and good luck,
LT
Michael said:
Hello,
i'm looking to find the top 5 sales by salesmen for each item sold. below
is my query - it is returning just the top 5 salesmen.
any help would be appreciated:
SELECT TOP 5
Query2.Item,
Query2.Salesmen, Query2.Sales
FROM Query2
ORDER BY Query2.Sales DESC;