Hello
I have this query below. It should return top 20 names where number of accidents is the highest. Instead I get everybody not just 20. Not sure what is the problem. Please help.
SELECT TOP 20 staff.[LAST NAME] & ", " & staff.[first NAME] AS [Names], Count(ClientIncidentReportsStaff.[Report ID]) AS Incidents, [Client Incident Reports].Date
FROM (ClientIncidentReportsStaff INNER JOIN [Client Incident Reports] ON ClientIncidentReportsStaff.[Report ID] = [Client Incident Reports].[Report ID]) INNER JOIN Staff ON ClientIncidentReportsStaff.[Staff Name] = Staff.[Staff ID]
WHERE (((Staff.[staff id])=[ClientIncidentReportsStaff].[Staff Name]) AND (([Client Incident Reports].Date)>=#10/1/2010# And ([Client Incident Reports].Date)<=#10/31/2010#) AND (([Client Incident Reports].[Restraint Minutes]) Is Not Null))
GROUP BY staff.[LAST NAME] & ", " & staff.[first NAME], [Client Incident Reports].Date
ORDER BY Incidents DESC;