First, my apologies if the title of this post is overly cryptic. I have a data set identifying events (academic courses) including start and end times. I want to verify that the times entered fit into a prescribed set of start and end times (slots), and spit out a report flagging courses that do not fit the prescribed slots. I also need to exclude courses with Section and/or Location codes that don't need to be checked.
I have the following tables:
Output: Course, Sec, Start, End, Location
Slots: Slot, SlotStart, SlotEnd, Term
Roomless (location codes): ID, OffcLoc
RoomlessSection s: id, Section
My process is:
1. exclude Output.Sec = RoomlessSection s.Section
2. exclude Output.Location = Roomless.OffcLo c
3. identify Slots.Slot where Output.Start = Slots.SlotStart
4. identify Slots.Slot where Output.End = Slots.SlotEnd
5. produce a report with the following:
Further complicating things, the Slot Start and End times are not unique values (For example: Slot 6 is 11:30-12:20 and Slot 9 is 11:30-12:45), so I have to compare a list of possible slots based on each of Start and End to see if there is a match.
My approach has been to first try to produce the results in separate queries, thus:
Possible Start Slots:
and Possible End Slots:
Then compare the two:
Finally, I use a fourth Query to analyze the data:
I'm using a make table so that I can run the report separate from the query, as (I realize) running four queries like this is extremely inefficient and slow.
I know I'm going about this the hard way, but I don't know how else to build this kind of comparison.
Extra Info :
My Slots table looks like this:
Notice how a number of start and end times repeat, and not necessarily in the same pairings. ie: 2:30 pm SlotStart shows up three times, with two different End times.
So, if I have a course with a 2:30 start, I need to be able to accept 3:45 pm or 5:15 pm as valid End times. This is why I'm trying to identify along the lines of 'if a 2:30 start could possibly be slots 11, 13 or 15, does my end time match the end times for these slots.'
So far, my efforts don't seem to be working. I think my problem is in my JOINs, but I'm not familiar enough with this kind of query to understand why.
I have the following tables:
Output: Course, Sec, Start, End, Location
Slots: Slot, SlotStart, SlotEnd, Term
Roomless (location codes): ID, OffcLoc
RoomlessSection s: id, Section
My process is:
1. exclude Output.Sec = RoomlessSection s.Section
2. exclude Output.Location = Roomless.OffcLo c
3. identify Slots.Slot where Output.Start = Slots.SlotStart
4. identify Slots.Slot where Output.End = Slots.SlotEnd
5. produce a report with the following:
a. Start not found in Slots
b. End not found in Slots
c. Start and End not in matching Slot
b. End not found in Slots
c. Start and End not in matching Slot
Further complicating things, the Slot Start and End times are not unique values (For example: Slot 6 is 11:30-12:20 and Slot 9 is 11:30-12:45), so I have to compare a list of possible slots based on each of Start and End to see if there is a match.
My approach has been to first try to produce the results in separate queries, thus:
Possible Start Slots:
Code:
SELECT Output.ID, Slots.Slot AS PossibleStartSlot FROM [Output] LEFT JOIN Slots ON (Output.Start=Slots.SlotStart) AND (Output.Term=Slots.TermUnique);
Code:
SELECT Output.ID, Slots.Slot AS PossibleEndSlot FROM [Output] LEFT JOIN Slots ON (Output.End = Slots.SlotEnd) AND (Output.Term = Slots.TermUnique);
Code:
SELECT Output.ID, qryPossibleStartSlots.PossibleStartSlot, qryPossibleEndSlots.PossibleEndSlot FROM [Output] INNER JOIN (qryPossibleStartSlots INNER JOIN qryPossibleEndSlots ON (qryPossibleStartSlots.PossibleStartSlot = qryPossibleEndSlots.PossibleEndSlot) AND (qryPossibleStartSlots.ID = qryPossibleEndSlots.ID)) ON Output.ID = qryPossibleStartSlots.ID;
Code:
SELECT Output.Department AS Department, Output.Course AS Course, Output.Sec AS Sec, Output.Title AS Title, Output.Start1 AS Start1, Output.End1 AS End1, Output.Start AS Start, Output.End AS [End], IIf([Output].[ID] In (select ID from qryMatchedStartEndSlots),"",IIf(IsNull([Output].[Start]),"No Start Time","Start Time Mismatch")) AS StartCheck, IIf(IsNull(Output.End),"No End Time","End Time Mismatch") AS EndCheck INTO SlotCheck FROM ([Output] LEFT JOIN RoomlessSections ON Output.Sec=RoomlessSections.Section) LEFT JOIN Roomless ON Output.Location=Roomless.OffcLoc WHERE (([Output].[Location] Not In (Select OffcLoc from Roomless)) AND ([Output].[Sec] Not In (Select Section from RoomlessSections)));
I know I'm going about this the hard way, but I don't know how else to build this kind of comparison.
Extra Info :
My Slots table looks like this:
Code:
Slot SlotStart SlotEnd Term 1 8:30 AM 9:20 AM FW 2 9:30 AM 10:20 AM FW 3 10:30 AM 11:20 AM FW 4 8:30 AM 9:45 AM FW 5 10:00 AM 11:15 AM FW 6 11:30 AM 12:20 PM FW 7 12:30 PM 1:20 PM FW 8 1:30 PM 2:20 PM FW 9 11:30 AM 12:45 PM FW 10 1:00 PM 2:15 PM FW [B][u]11 2:30 PM 3:45 PM FW[/u][/B] 12 4:00 PM 5:15 PM FW [B][u]13 2:30 PM 3:45 PM FW[/u][/B] 14 4:00 PM 5:15 PM FW [B][u]15 2:30 PM 5:15 PM FW[/u][/B]
So, if I have a course with a 2:30 start, I need to be able to accept 3:45 pm or 5:15 pm as valid End times. This is why I'm trying to identify along the lines of 'if a 2:30 start could possibly be slots 11, 13 or 15, does my end time match the end times for these slots.'
So far, my efforts don't seem to be working. I think my problem is in my JOINs, but I'm not familiar enough with this kind of query to understand why.
Comment