I'm new to Access and need some help on how to group the results for a query. Here are the details.
tblEmployees
intDistrictCode-Pirmary Key
typEmployeeCode Primary Key
typLastName
typFirstName
tblAppsPoints
typEmployeeCode-Primary Key
intApps
intPoints
This query returns me all the districts with all the employees and their point and app totals sorted by districts accesending then by points decending.
Query
SELECT tblEmployees.intDistrictCode, tblEmployees.typEmployeeCode, tblEmployees.typLastName, tblEmployees.typFirstName, tblAppsPoints.intPoints, tblAppsPoints.intApps
FROM tblEmployees INNER JOIN tblAppsPoints ON tblEmployees.typEmployeeCode = tblAppsPoints.typEmployeeCode
ORDER BY tblEmployees.intDistrictCode, tblAppsPoints.intPoints DESC;
I need it cut down to the top 3 for each district, and when I tell access to return the top 3 with this query:
Query
SELECT TOP 3 tblEmployees.intDistrictCode, tblEmployees.typEmployeeCode, tblEmployees.typLastName, tblEmployees.typFirstName, tblAppsPoints.intPoints, tblAppsPoints.intApps
FROM tblEmployees INNER JOIN tblAppsPoints ON tblEmployees.typEmployeeCode = tblAppsPoints.typEmployeeCode
ORDER BY tblEmployees.intDistrictCode, tblAppsPoints.intPoints DESC;
I only get the top 3 for the first district in the accending order. Can anyone tell me how to get it to return the top 3 for the other districts also?