I am trying to find the Maximum value of a count query below. Each employee can see multiple customers and I want to return only the employee who had the highest count per customer. For example, emplyee ID #1, 2, and 3 saw customer #1 10, 20 and 30 times respectively. I only want to return employee ID #3 in my query for that particular customer (so on and so forth). The query below does not work because the Max function returns employees 1,2 and 3 because they have different numbers. Any help is appreciated. Thanks
Code:
SELECT aCount.[EmployeeID], Max(aCount.[Panel Size]) AS [Highest]
FROM (SELECT [EmployeeID], tbl1.[CustomerID], Count([CustomerID]) AS [Panel Size]
FROM tbl1
GROUP BY [EmployeeID], CustomerID]) AS aCount
GROUP BY [EmployeeID]