Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi.i am novice with sql server oracle and I have a question:
I have 2 tables: tab Rooms
ID
RoomName tab Reservations
ID
DateStart
DateEnd
Status
Comment ID_Rooms Basic idea that I have a list of rooms in tab
Rooms, and reservations for that rooms in tab
Reservations. DateStart and DateEnd are
SmallDateTime type. My problem is to make sql query which will get 2
input parameters (DateStart and DateEnd),
and will return all rooms which are NOT reserved
in period between DateStart and DateEnd. Thanks!
Posted
Comments
F-ES Sitecore 4-Aug-15 10:41am    
This is a very popular homework subject and a very popular question. Do a google search and you'll find various solutions.
Member 11885166 4-Aug-15 10:43am    
sorry,bt i m nt able find out the solution,please help if u know

1 solution

Easiest way is using a temporal auxiliary that holds dates for a large period of time. For example, 1-1-2000 up until 1-1-2050. You can then easily select all dates from the auxiliary table and join it with the tables holding the room information/reservations. There are also some nice books on this subject like Joe Celko's thinking in sets.

Good luck!
 
Share this answer
 
Comments
Member 11885166 4-Aug-15 10:31am    
i cant get u..can u please write the sql query fr d same,please
E.F. Nijboer 4-Aug-15 10:56am    
It is not what this site is about. The people on codeproject (including me) aren't going to write the code for you. We try to help you in the right direction but it still is up to you to do the programming. otherwise you just need to hire a developer somewhere.
Member 11885166 4-Aug-15 11:00am    
so can u tell some sites from where i can referr
E.F. Nijboer 4-Aug-15 11:08am    
http://pratchev.blogspot.nl/2007/12/auxiliary-tables.html

The example for Calendar creates an auxiliary for 2008 and also adds workday information. After that is shows to easily count all the workdays. You could use the same sort of mechanism.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900