Show all records in parameter query

Chris Howarth

Registered User.
Local time
Today, 09:32
Joined
Oct 10, 2002
Messages
11
I have two related tables, tmain and a look up table for AccidentCauses. I can show all records for all accident causes (including those with no accidents) with the following SQL:-

SELECT tAccidentCauses.AccidentCause, Count(tMain.IncidentID) AS CountOfIncidentID
FROM tAccidentCauses LEFT JOIN tMain ON tAccidentCauses.AccidentCauseID = tMain.AccidentCause
GROUP BY tAccidentCauses.AccidentCause
ORDER BY Count(tMain.IncidentID) DESC;

However, I'd like to make it a parameter query so people can see accidents by year. When I use the SQL below, though I can only seem to show accident causes that have associated records. Anyone have an idea on what I need to do? Thanks in advance.

SELECT tAccidentCauses.AccidentCause, Count(tMain.IncidentID) AS CountOfIncidentID
FROM tAccidentCauses LEFT JOIN tMain ON tAccidentCauses.AccidentCauseID = tMain.AccidentCause
GROUP BY tAccidentCauses.AccidentCause, Year([incdate])
HAVING (((Year([incdate]))=[Enter Year]))
ORDER BY Count(tMain.IncidentID) DESC;

Edit: wrong SQL for second bit :rolleyes:
 
Last edited:

Users who are viewing this thread

Back
Top Bottom