I have the following query, and am counting the total number of bookings and need to check against the capacity to ensure that I do not overbook.
On any session(tblSessions table) the total number of bookings should be <= to the capacity(tblVenues table).
Now the query below shows the total bookings per SessionID.
I need to select all the sessions from my table which have less bookings than the capacity.
Do I need to do something like IIF(Count(tblBookings.BookingID)) <= tblVenues.Capacity then select this SessionID in my select statement.
SELECT Count(tblBookings.BookingID), tblSessions.SessionID
FROM (tblVenues INNER JOIN tblSessions ON tblVenues.VenueID = tblSessions.VenueID) INNER JOIN tblBookings ON tblSessions.SessionID = tblBookings.SessionID
GROUP BY tblSessions.SessionID
Please can you help.
On any session(tblSessions table) the total number of bookings should be <= to the capacity(tblVenues table).
Now the query below shows the total bookings per SessionID.
I need to select all the sessions from my table which have less bookings than the capacity.
Do I need to do something like IIF(Count(tblBookings.BookingID)) <= tblVenues.Capacity then select this SessionID in my select statement.
SELECT Count(tblBookings.BookingID), tblSessions.SessionID
FROM (tblVenues INNER JOIN tblSessions ON tblVenues.VenueID = tblSessions.VenueID) INNER JOIN tblBookings ON tblSessions.SessionID = tblBookings.SessionID
GROUP BY tblSessions.SessionID
Please can you help.