Re: finding continuous range
Date: Sat, 12 May 2001 18:25:20 GMT
Message-ID: <kefL6.5580$%i7.5542752_at_news1.rdc1.sfba.home.com>
"Jan Hidders" <hidders_at_REMOVE.THIS.win.tue.nl> wrote in message news:9dhjap$6g9$1_at_news.tue.nl...
> SELECT sd1.startdate, ed1.enddate
> FROM startdates AS sd1, enddates AS ed1
> WHERE NOT EXISTS (
> SELECT *
> FROM enddates AS ed2
> WHERE ed2.enddate BETWEEN sd1.startdate AND ed1.enddate
> AND NOT EXISTS (
> SELECT *
> FROM schedules AS sc
> WHERE sc.startdate <= ed2.enddate
> AND sc.enddate > ed2.enddate
> )
> );
Hmm... That's pretty much like "frequent drinker example" from Victor Vianu's "Databases and Finite-Model Theory" paper I read yesterday. He explaines that ordinary SQL statement is essentially:
{x1:A1,...,xn:An | exists u (L1&...&Lk) }
so that one have to unfold the query into a sequence of existentially quantified nested queries like you did.
Now, in your original solution I don't see 2 levels of 'EXIST' and that makes me suspicious that it would work (I don't have SQL today at hand as well, but will test your corrected statement monday;-). Unless you would be kind to explain where second EXISTS collapsed. Received on Sat May 12 2001 - 20:25:20 CEST
