Im getting interval times via:
SELECT time_col - lag(time_col) OVER (ORDER BY whatever)
FROM myTable where conditions
This returns a table like this:
00:00:38
00:05:10
00:02:05
...
I want to have the time in seconds like this:
38
310
125
...
Here is my approach:
SELECT EXTRACT(epoch from dt) from (SELECT time_col - lag(time_col) OVER (ORDER BY whatever) FROM myTable where conditions) as dt
dt should be the table with the difference times (intervals). However I get the following error:
Error: Function pg_catalog.date_part(unknown, record) does not exist
So I have to cast record (the table 'dt') to interval? How do I do that? Or is this completely wrong? Sorry Im new to database queries....