G
Guest
I am handling the bookings for a tennis court.
Each member is allowed to book up to 3 courts in any 7 day period BUT NO
MORE THAN THAT! The maximum period 'ahead' of 'today' that they can book is
also 7 days. This limits our interest to an ABSOLUTE maximum of 7 days ahead
and 7 days prior to today's date
The court times (slots) is held in a table which shows the date and time of
ALL the slots available up to 7 days into the future. A member has booked a
slot when their RefNo is placed in a specific 'slot'. Each 'slot' is 1 hour
in length and all the 'slots' are held in a datetime field/variable. No one
can book any court more than 7 days into the future.
I need a SINGLE (for speed purposes) query (SQL) which returns the NEXT
time/date the member is allowed to play.
The rules are:
If there are 0, 1, or 2 courts booked to a single member within in the 7
days PRIOR to the most-future booked 'slot', they can book at anytime/date up
to 7 days in the future.
If they already HAVE 3 courts booked to them within 7 days of the
most-future booked slot, at what time/date can they NEXT be allowed to book a
court? So, if they have 3 slots booked (e.g. 10am Tues, 3pm Weds and 4pm
Thursday), they will ONLY be allowed to play after 10.am NEXT Tuesday.
Can anything this complex be held in a single query/SQL?
ian
Each member is allowed to book up to 3 courts in any 7 day period BUT NO
MORE THAN THAT! The maximum period 'ahead' of 'today' that they can book is
also 7 days. This limits our interest to an ABSOLUTE maximum of 7 days ahead
and 7 days prior to today's date
The court times (slots) is held in a table which shows the date and time of
ALL the slots available up to 7 days into the future. A member has booked a
slot when their RefNo is placed in a specific 'slot'. Each 'slot' is 1 hour
in length and all the 'slots' are held in a datetime field/variable. No one
can book any court more than 7 days into the future.
I need a SINGLE (for speed purposes) query (SQL) which returns the NEXT
time/date the member is allowed to play.
The rules are:
If there are 0, 1, or 2 courts booked to a single member within in the 7
days PRIOR to the most-future booked 'slot', they can book at anytime/date up
to 7 days in the future.
If they already HAVE 3 courts booked to them within 7 days of the
most-future booked slot, at what time/date can they NEXT be allowed to book a
court? So, if they have 3 slots booked (e.g. 10am Tues, 3pm Weds and 4pm
Thursday), they will ONLY be allowed to play after 10.am NEXT Tuesday.
Can anything this complex be held in a single query/SQL?
ian