From: | Adam Jensen <hanzer(at)riseup(dot)net> |
---|---|
To: | "pgsql-sql(at)lists(dot)postgresql(dot)org" <pgsql-sql(at)lists(dot)postgresql(dot)org> |
Subject: | Re: interval origami |
Date: | 2018-11-30 20:19:10 |
Message-ID: | d05565aa-551d-fac3-ba88-8215c8cbe0d4@riseup.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On 11/30/18 12:57 PM, Alvaro Herrera wrote:
> This sounds like something you can easily do with range types in
> Postgres. Probably not terribly portable to other DBMSs though.
> https://www.postgresql.org/docs/11/rangetypes.html
Nice hint. Thanks!
PostgreSQL as the application platform is fine. Portability to other
DBMS's isn't a requirement.
The 'numrange' type with the 'overlaps' and 'intersection' operators
seem to cover the fundamental computations in a very natural way.
hanzer=# SELECT numrange(10, 30) && numrange(12, 32);
?column?
----------
t
(1 row)
hanzer=# SELECT numrange(10, 30) * numrange(12, 32);
?column?
----------
[12,30)
(1 row)
How might they be used in an SQL query to solve the problem? I'm an SQL
noob. Seeing a few examples would be very informative. My impression is
that it might require some serious kung-fu. :)
From | Date | Subject | |
---|---|---|---|
Next Message | Adam Jensen | 2018-11-30 21:02:24 | Re: interval origami |
Previous Message | Alvaro Herrera | 2018-11-30 17:57:19 | Re: interval origami |