Re: Clever way to check overlapping time intervals ? - Mailing list pgsql-sql

From Frank Bax
Subject Re: Clever way to check overlapping time intervals ?
Date
Msg-id 4E732FB7.50009@sympatico.ca
Whole thread Raw
In response to Clever way to check overlapping time intervals ?  (Andreas <maps.on@gmx.net>)
List pgsql-sql
On 09/15/11 19:40, Andreas wrote:
> Hi,
> is there a clever way to check overlapping time intervals ?
> An option named n should be taken from date y to y.
> The same name is ok for another interval.
>
> e.g. table : mytab ( d1 date, d2 date, n text, v text )
>
> There should be a constraint to provide no row can have a d1 or d2
> within the interval of another row in case they have the same n.
>
> And no row can have an interval that encloses an existing interval.
>


self join with "OVERLAPS" operator:

select t1.*,t2.* from (select * from mytab) as t1    full join (select * from mytab) as t2    where (t1.d1,t1.d2)
overlaps(t2.d1,t2.d2)
 



pgsql-sql by date:

Previous
From: pasman pasmański
Date:
Subject: Re: Clever way to check overlapping time intervals ?
Next
From: Tim Landscheidt
Date:
Subject: Re: Window function sort order help