| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Hotel Booking dates subquery
In article <99irsusn3hl706ov9saqp4n63uaublvvsg_at_4ax.com>,
Scotty <invallid_at_invalid.spam> wrote:
> Scotty wrote:
> select * from booking
> where booking_id not in (
> select booking_id
> from booking
> where to_date('02-06-01','dd-mm-yy') -- starting date
> between to_date( startdate,'dd-mm-yy')
> and to_date( enddate,'dd-mm-yy')
> or to_date('12-06-01','dd-mm-yy') -- ending date
> between to_date(startdate,'dd-mm-yy')
> and to_date(enddate,'dd-mm-yy'));
Suppose there is a booking with startdate = 3-06-01 and enddate = 11-06-01. Does this query still work?
Free hint: forget about "between" - it's not actually useful. There's a correct query with just two linear comparisons.
Another hint: when do two periods of time _not_ overlap?
Sean Case
-- Sean Case gsc_at_zip.com.au Code is an illusion. Only assertions are real.Received on Sat Nov 09 2002 - 22:54:49 CST
![]() |
![]() |