Re: Absolute value of intervals
От | Jasen Betts |
---|---|
Тема | Re: Absolute value of intervals |
Дата | |
Msg-id | hdr2if$7af$1@reversiblemaps.ath.cx обсуждение исходный текст |
Ответ на | Absolute value of intervals (Joshua Berry <yoberi@gmail.com>) |
Список | pgsql-general |
On 2009-11-07, Joshua Berry <yoberi@gmail.com> wrote: > On Mon, Nov 2, 2009 at 8:35 AM, Jasen Betts <jasen@xnet.co.nz> wrote: >| >| for this case: convert to seconds and then do abs. >| >| select * from enviados e, recibidos r where abs(extract ( epoch from >| (e.fecha - r.fecha) )) < 1 > > Cheers for that. The query cost is pretty heavy, but the same as the > following query which involves two WHERE sections: indeed, this one should be more efficient but is not exactly identical. select * from enviados e, recibidos r where e.fecha between r.fecha -'1s' and r.fecha +'1s'; the difference being that the above includes the case where the difference is exactly 1 second. this might work better: select * from enviados e, recibidos r where e.fecha between r.fecha -'0.999999s' and r.fecha +'0.999999s'; it depends how critical the edge cases are.
В списке pgsql-general по дате отправления: