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

Estrarre i secondi dalla tabella degli intervalli / Trasmettere il record all'intervallo?

O questo

SELECT EXTRACT(epoch from dt)
from (
    SELECT time_col - lag(time_col) OVER (ORDER BY whatever) dt
    FROM myTable
    where conditions
) as dt

O questo

SELECT
    extract(epoch from time_col - lag(time_col) OVER (ORDER BY whatever))
FROM myTable
where conditions