Pretty nifty Larry.  Really shows how powerful SQL is.

-- Dennis McGrath
mailto:[EMAIL PROTECTED]

-- Productivity Tools for R:Base Programmers
http://www.enteract.com/~mcgrath/dennis

-- Full time consultant with:
SQL Resources Group
Steve Hartmann
Oak Park, IL
mailto:[EMAIL PROTECTED]


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Lawrence Lustig
Sent: Tuesday, October 23, 2001 9:25 PM
To: [EMAIL PROTECTED]
Subject: Re: SQL Impossibility?


Sorry for the premature send on the previous response.

> Is there an SQL way to return the empty slots:
> 13:00 13:30
> 14:30 15:00

SELECT End, MIN(t3.Start) +
  FROM YourTable t1, YourTable t3 +
  WHERE NOT EXISTS +
  (SELECT * FROM YourTable t2 WHERE t2.Start = t1.End) +
  AND t3.Start > t1.End +
  GROUP BY  End

Translated into "English Query Language" this says:

Select all the End times that are not also in the table as a Start time (the
NOT EXISTS part) and also give me the minimum Start time that is greater
than the selected End time.  The period from the "unstarted" end to the next
highest start time is a hole in the schedule.

--
Larry



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



Reply via email to