PostgreSQL
 sql >> Base de données >  >> RDS >> PostgreSQL

Extraire les secondes de la table d'intervalles/Cast record to interval ?

Soit ça

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

Ou ceci

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