time_delta()

The observed change in time. Calculated by subtracting the first observed time from the last observed time over the period aggregated. Measured in seconds.

time_delta(
    summary CounterSummary
) RETURNS DOUBLE PRECISION

For more information about counter aggregation functions, see the hyperfunctions documentation.

Required arguments

NameTypeDescription
summaryCounterSummaryThe input CounterSummary from a counter_agg call

Returns

NameTypeDescription
time_deltaDOUBLE PRECISIONThe total duration in seconds between the first and last observed times in the CounterSummary

Sample usage

SELECT
    id,
    bucket,
    time_delta(summary)
FROM (
    SELECT
        id,
        time_bucket('15 min'::interval, ts) AS bucket,
        counter_agg(ts, val) AS summary
    FROM foo
    GROUP BY id, time_bucket('15 min'::interval, ts)
) t

Found an issue on this page?

Report an issue!

Related Content