RobertSOakes
New member
- Local time
- Yesterday, 19:16
- Joined
- Feb 12, 2007
- Messages
- 4
I am trying to write a fairly complicated SQL statement in Microsoft Access and I don’t quite know how to do it.
The Basic Challenge: I need to query for individuals who have received 4 or fewer employee evaluations within a given time period. This works just fine as long they have as they have at least one evaluation, but fails if they don’t have any (the vast majority of the group). Does anyone know of any way to get it to include the results for individuals who have zero?
Here is the code I’ve put together so far:
SELECT [CSU Staff].ID, [Last Name] & ', ' & [First Name] AS FullName, [CSU Staff].[Currently Employed], Count([EvalID]) AS [Evaluation Count]
FROM [CSU Staff] LEFT JOIN [Surgical Employee Evaluations] ON [CSU Staff].ID = [Surgical Employee Evaluations].[Peer Evaluated]
WHERE ((([Surgical Employee Evaluations].Date)>#12/29/2006#))
GROUP BY [CSU Staff].ID, [Last Name] & ', ' & [First Name], [CSU Staff].[Currently Employed]
HAVING ((([CSU Staff].[Currently Employed])=Yes))
ORDER BY [Last Name] & ', ' & [First Name];
I thought I may have had better luck writing a Subquery statement, but this is proving beyond my rather meager abilities. Also, I will eventually need to make this date dependant, but I have already written some Visual Basic which will automatically construct the date ranges. I just need to get Acess to Include Individuals who do not have any evaluations.
Any advice or ideas would be greatly appreciated.
The Basic Challenge: I need to query for individuals who have received 4 or fewer employee evaluations within a given time period. This works just fine as long they have as they have at least one evaluation, but fails if they don’t have any (the vast majority of the group). Does anyone know of any way to get it to include the results for individuals who have zero?
Here is the code I’ve put together so far:
SELECT [CSU Staff].ID, [Last Name] & ', ' & [First Name] AS FullName, [CSU Staff].[Currently Employed], Count([EvalID]) AS [Evaluation Count]
FROM [CSU Staff] LEFT JOIN [Surgical Employee Evaluations] ON [CSU Staff].ID = [Surgical Employee Evaluations].[Peer Evaluated]
WHERE ((([Surgical Employee Evaluations].Date)>#12/29/2006#))
GROUP BY [CSU Staff].ID, [Last Name] & ', ' & [First Name], [CSU Staff].[Currently Employed]
HAVING ((([CSU Staff].[Currently Employed])=Yes))
ORDER BY [Last Name] & ', ' & [First Name];
I thought I may have had better luck writing a Subquery statement, but this is proving beyond my rather meager abilities. Also, I will eventually need to make this date dependant, but I have already written some Visual Basic which will automatically construct the date ranges. I just need to get Acess to Include Individuals who do not have any evaluations.
Any advice or ideas would be greatly appreciated.