Re: SQL for intervals
Date: 2 Dec 2006 05:35:55 -0800
> 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