Re: interval origami - Mailing list pgsql-sql

From Adam Jensen
Subject Re: interval origami
Date
Msg-id d05565aa-551d-fac3-ba88-8215c8cbe0d4@riseup.net
Whole thread Raw
In response to Re: interval origami  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: interval origami
List 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. :)


pgsql-sql by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: interval origami
Next
From: Adam Jensen
Date:
Subject: Re: interval origami