Hi Guys,
I am trying to build a report that will present data from 2 sql tables. Here is the scenario:
I have 2 Tbales:
1. TimeSlots - has SlotID and Time columns
2. Reserv - has SlotID, Name, Comments, Date
I am trying to build a report that will show all SlotID's from TimeSlots for a certain Day. The report should show all Time slots regardles if there is a reservation for that TimeSlot, also the Name and Comments for the Time Slot that is reserved.
The idea is that if a time slot is not reserved it should still print on the report which will then be given to the user who will manually pencil in the data should a pop up reservation occurs.
For Example:
SlotID Time Name Comments
1 6:00
2 6:15 Sven Employee
3 7:00 Randy Employee
4 7:15
Please help as i am lost!
regards
SD
You should be able to build your query something like the following:
SELECT ts.SlotID, ts.Time, res.Name, res.Comments, res.Date
FROM TimeSlots ts
LEFT OUTER JOIN Reserve res
ON ts.SlotID = res.SlotID
This will return all records in the TimeSlots table with any corresponding Reserve records based on the SlotID fields. The main thing to ensure is to uniquely identify any fields that may have duplicate names and returning duplicate field names via a subquery will throw a SQL error (just in case you weren't aware of this). You should be able to just pull the necessary fields onto your report from here.
Hope this helps.
|||For those of you intrested, I used an Union query and build a report that groups the data on SotID!
Regards
SD
No comments:
Post a Comment