Versions:
first_time, last_time
ToolkitTimescaleDB Toolkit functions are available under Timescale Community Edition. They are automatically included with Timescale Cloud. Click to learn more.This pair of functions returns the timestamps of the first and last points in a CounterSummary
aggregate.
first_time(cs CounterSummary) RETURNS TIMESTAMPTZ
last_time(cs CounterSummary) RETURNS TIMESTAMPTZ
Name | Type | Description |
---|---|---|
cs | CounterSummary | The input CounterSummary from a previous counter_agg (point form) call, often from a continuous aggregate |
Column | Type | Description |
---|---|---|
first_time | TIMESTAMPTZ | The time of the first point in the CounterSummary |
Column | Type | Description |
---|---|---|
last_time | TIMESTAMPTZ | The time of the last point in the CounterSummary |
This example produces a CounterSummary from timestamps and associated values,
then applies the first_time
and last_time
accessors:
WITH t as (SELECTtime_bucket('1 day'::interval, ts) as dt,counter_agg(ts, val) AS cs -- get a CounterSummaryFROM tableGROUP BY time_bucket('1 day'::interval, ts))SELECTdt,first_time(cs) -- extract the timestamp of the first point in the CounterSummarylast_time(cs) -- extract the timestamp of the last point in the CounterSummaryFROM t;
Found an issue on this page?
Report an issue!