I have an exercise I need to give to my pupils (I'm a teacher!) and I am trying to get a query working preferably using the query design view, without having to edit the SQL. The query involves three tables; Admission, Ward & Patient. The query is to initially return a list of all the wards with the total number of patients on each one. This is fine, using the following SQL:
Expand|Select|Wrap|Line Numbers
- SELECT Wards.Name, Wards.[Number Bed], Count(Patients.[Pat-id]) AS [CountOfPat-id]
- FROM Wards INNER JOIN (Patients INNER JOIN Admissions ON Patients.[Pat-id] = Admissions.[Pat-id]) ON Wards.[Ward-id] = Admissions.[Ward-id]
- GROUP BY Wards.Name, Wards.[Number Bed];
Expand|Select|Wrap|Line Numbers
- SELECT Wards.Name, Wards.[Number Bed], Count(Patients.[Pat-id]) AS [CountOfPat-id], Admissions.[Start Date], Admissions.[End Date]
- FROM Wards INNER JOIN (Patients INNER JOIN Admissions ON Patients.[Pat-id] = Admissions.[Pat-id]) ON Wards.[Ward-id] = Admissions.[Ward-id]
- GROUP BY Wards.Name, Wards.[Number Bed], Admissions.[Start Date], Admissions.[End Date]
- HAVING (((Admissions.[Start Date])<Now()) AND ((Admissions.[End Date])>Now()));
Can anyone clear up how I can change this in design view to only return one record per ward regardless of the dates.
The end result will be to present this in a report. I have toyed with the idea of filtering the report using the initial query, but wnat to avoid overcomplicating things for the pupils.
I hope this makes sense and thanks for the help.
Cheers
Guy