I would like to use the following SQL to take the derivative of the data, but EXTRACT does not work as expected, is there an alternative way?
SELECT
time,
value,
(value - LAG(value) OVER (ORDER BY time)) / EXTRACT(EPOCH FROM (time - LAG(time) OVER (ORDER BY time))) AS derivative
FROM
(VALUES
('2024-01-01 00:00:00'::TIMESTAMP, 10.0),
('2024-01-01 00:01:00'::TIMESTAMP, 12.0),
('2024-01-01 00:02:00'::TIMESTAMP, 15.0),
('2024-01-01 00:03:00'::TIMESTAMP, 18.0),
('2024-01-01 00:04:00'::TIMESTAMP, 20.0)
) AS data(time, value);