B
Bill Hamill
Greetings,
I'm having a *major* problem with some query logic and was
hoping somebody could help me 'think outside the box'.
Here's my pseudo-code:
Search Reservations Table within a user specified time
frame (Start Date & End Date ... parameters)
Output a generic label, Reservations.ArrivalDate, Sum
(Reservations.Units)
Discriminators
1. Reservations.MRKT = "I"
2. Reservations.ArrivalDate - Reservations.BookingDate <=
7 days
Real basic: I need the query to return all results from
the user-specified time frame, but the daily totals can
only be drawn from the past 7 days.
Now here where I'm screwing up: The calculations (Arrival
Date, Rooms Sold This Past Week) are exact, but ONLY for 7
Days! Looks as if my 'Where' Statement is pulling double
duty; restricting the sum calculation to just the previous
week AND RESTRICTING THE DATES RETURNED TO ONLY 7 DAYS!
INSERT INTO RoomSaleCount ( [Sub-Market], [Arrival Date],
[Rooms Sold] )
SELECT "Internet" AS [Sub-Market], Reservations.ARRIVAL AS
[Arrival Date], Sum(Reservations.UNITS) AS [Rooms Sold]
FROM Reservations
WHERE (((DateDiff("d",[Reservations]![BOOKING],
[Reservations]![ARRIVAL]))<=7) AND ((Reservations.CANCEL)
Is Null) AND ((Reservations.MRKT)="I"))
GROUP BY "Internet", Reservations.ARRIVAL
HAVING (((Reservations.ARRIVAL) Between [Start Date] And
[End Date]))
ORDER BY Reservations.ARRIVAL;
I'm having a *major* problem with some query logic and was
hoping somebody could help me 'think outside the box'.
Here's my pseudo-code:
Search Reservations Table within a user specified time
frame (Start Date & End Date ... parameters)
Output a generic label, Reservations.ArrivalDate, Sum
(Reservations.Units)
Discriminators
1. Reservations.MRKT = "I"
2. Reservations.ArrivalDate - Reservations.BookingDate <=
7 days
Real basic: I need the query to return all results from
the user-specified time frame, but the daily totals can
only be drawn from the past 7 days.
Now here where I'm screwing up: The calculations (Arrival
Date, Rooms Sold This Past Week) are exact, but ONLY for 7
Days! Looks as if my 'Where' Statement is pulling double
duty; restricting the sum calculation to just the previous
week AND RESTRICTING THE DATES RETURNED TO ONLY 7 DAYS!
INSERT INTO RoomSaleCount ( [Sub-Market], [Arrival Date],
[Rooms Sold] )
SELECT "Internet" AS [Sub-Market], Reservations.ARRIVAL AS
[Arrival Date], Sum(Reservations.UNITS) AS [Rooms Sold]
FROM Reservations
WHERE (((DateDiff("d",[Reservations]![BOOKING],
[Reservations]![ARRIVAL]))<=7) AND ((Reservations.CANCEL)
Is Null) AND ((Reservations.MRKT)="I"))
GROUP BY "Internet", Reservations.ARRIVAL
HAVING (((Reservations.ARRIVAL) Between [Start Date] And
[End Date]))
ORDER BY Reservations.ARRIVAL;