Re: SQL for intervals

From: Lennart <Erik.Lennart.Jonsson_at_gmail.com>
Date: 2 Dec 2006 05:35:55 -0800
Message-ID: <1165066555.722481.54770_at_16g2000cwy.googlegroups.com>


Lennart wrote:
[...]
>
> 3. Determine upper bound for each interval
>
> ), upper (id, min_date, max_date) as (
> select w.id, w.t, min(c.t) - 1 day from compl c, w
> where c.t > w.t
> group by w.id, w.t
> )

Grmpf, add the predicate c.id = w.id, i.e.

   where c.t > w.t and c.id = w.id

In addition to my nonexistent explanation before, what we do here is to find the least complement - 1 day that is bigger than t for current row. That is, the maximum t in this interval.

/Lennart Received on Sat Dec 02 2006 - 14:35:55 CET

Original text of this message