Re: Checking for schedule conflicts - Mailing list pgsql-general

From Greg Sabino Mullane
Subject Re: Checking for schedule conflicts
Date
Msg-id 1d37311813ee9c34476c1eae8e72388b@biglumber.com
Whole thread Raw
In response to Checking for schedule conflicts  (Benjamin Smith <lists@benjamindsmith.com>)
List pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Benjamin Smith wrote:
> Given the tables defined below, what's the easiest way to check for schedule
> conflicts?

Assuming you don't count more than once things with the same id, start, and finish:

SELECT COUNT(DISTINCT (s1.event_id||s1.start||s1.finish))
FROM sched s1, sched s2
WHERE s1.date = s2.date AND s1.start >= s2.start
  AND s2.finish <= s2.finish AND NOT s1.ctid = s2.ctid

Add "AND s1.date = $date" as needed.

- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200503140639
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iD8DBQFCNXgTvJuQZxSWSsgRAlBmAKC7hj8XzHzS7srqfgdSGOZiCfvtDQCfWM22
VXMkQB7IzEdTKjqpcmWVdaM=
=hFiy
-----END PGP SIGNATURE-----



pgsql-general by date:

Previous
From: Ragnar Hafstað
Date:
Subject: Re: Problem with special character �
Next
From: Jack Orenstein
Date:
Subject: Re: Logging VACUUM activity