barrybazouk
New member
- Local time
- Today, 11:42
- Joined
- Sep 16, 2008
- Messages
- 6
I Have the following query:
SELECT Count(tblBookings.BookingID) AS CountOfBookingID, tblSessions.SessionID, tblSessions.SessionDate
FROM tblCourses INNER JOIN ((tblVenues INNER JOIN tblSessions ON tblVenues.VenueID = tblSessions.VenueID) INNER JOIN tblBookings ON tblSessions.SessionID = tblBookings.SessionID) ON tblCourses.CourseID = tblSessions.CourseID
WHERE (((tblBookings.Status)<>4) AND (([tblCourses].[CourseID])=[@CourseID]) AND ((tblSessions.SessionID)=[@SessionID]))
GROUP BY tblSessions.SessionID, tblSessions.SessionDate
HAVING (((Count(tblBookings.BookingID))<Max([tblVenues].[Capacity])));
This takes as input @CourseID and @SessionID. It checks to see if the total number of bookings made by delegates is less than the Venues capacity.
There is only one problem with this, say if there is no bookings for a Session then it will not bring back any results. Even though you should be able to book Sessions for that course.
Your help is much appreciated.
SELECT Count(tblBookings.BookingID) AS CountOfBookingID, tblSessions.SessionID, tblSessions.SessionDate
FROM tblCourses INNER JOIN ((tblVenues INNER JOIN tblSessions ON tblVenues.VenueID = tblSessions.VenueID) INNER JOIN tblBookings ON tblSessions.SessionID = tblBookings.SessionID) ON tblCourses.CourseID = tblSessions.CourseID
WHERE (((tblBookings.Status)<>4) AND (([tblCourses].[CourseID])=[@CourseID]) AND ((tblSessions.SessionID)=[@SessionID]))
GROUP BY tblSessions.SessionID, tblSessions.SessionDate
HAVING (((Count(tblBookings.BookingID))<Max([tblVenues].[Capacity])));
This takes as input @CourseID and @SessionID. It checks to see if the total number of bookings made by delegates is less than the Venues capacity.
There is only one problem with this, say if there is no bookings for a Session then it will not bring back any results. Even though you should be able to book Sessions for that course.
Your help is much appreciated.