PostgreSQL
 sql >> Database >  >> RDS >> PostgreSQL

PostgreSQL e dati sequenziali

Se puoi usare PostgreSQL 8.4 allora funzioni finestra aiuterà:

SELECT *
    FROM (SELECT itemName, date, date - lag(date) OVER w AS gap
              FROM someTable WINDOW w AS (ORDER BY date)
         ) AS pairs
    WHERE pairs.gap > '1 day'::interval;