Skip to content

Latest commit

 

History

History
51 lines (50 loc) · 1.42 KB

first_time.md

File metadata and controls

51 lines (50 loc) · 1.42 KB
api_name excerpt topics api hyperfunction api_details
first_time()
Get the first timestamp from a counter aggregate
hyperfunctions
license type toolkit experimental version
community
function
true
false
stable
1.11.0
family type aggregates
counters and gauges
accessor
counter_agg()
summary signatures parameters examples
Get the first timestamp from a counter aggregate.
language code
sql
first_time( cs CounterSummary ) RETURNS TIMESTAMPTZ
required returns
name type description
cs
CounterSummary
A counter aggregate produced using [`counter_agg`](#counter_agg)
column type description
first_time
TIMESTAMPTZ
The timestamp of the first point in the counter aggregate
description command
Get the first and last point of each daily counter aggregate.
code
WITH t as ( SELECT time_bucket('1 day'::interval, ts) as dt, counter_agg(ts, val) AS cs -- get a CounterSummary FROM table GROUP BY time_bucket('1 day'::interval, ts) ) SELECT dt, first_time(cs) -- extract the timestamp of the first point in the CounterSummary last_time(cs) -- extract the timestamp of the last point in the CounterSummary FROM t;