agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Adam Jensen <hanzer@riseup.net>
To: pgsql-sql@lists.postgresql.org <pgsql-sql@lists.postgresql.org>
Subject: Re: interval origami
Date: Fri, 30 Nov 2018 15:19:10 -0500
Message-ID: <d05565aa-551d-fac3-ba88-8215c8cbe0d4@riseup.net> (raw)
In-Reply-To: <20181130175719.l7izv65wjwgkls35@alvherre.pgsql>
References: <20181130175719.l7izv65wjwgkls35@alvherre.pgsql>
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. :)
view thread (10+ messages) latest in thread
Message-ID: <d05565aa-551d-fac3-ba88-8215c8cbe0d4@riseup.net>
Permalink: ../d05565aa-551d-fac3-ba88-8215c8cbe0d4@riseup.net/
Also on: postgresql.org/message-id/d05565aa-551d-fac3-ba88-8215c8cbe0d4@riseup.net
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: hanzer@riseup.net, pgsql-sql@lists.postgresql.org
Subject: Re: interval origami
In-Reply-To: <d05565aa-551d-fac3-ba88-8215c8cbe0d4@riseup.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox