v1.1
first()/last()
Function
cmp_col is used for comparison to return the value of the column specified by the first or last value. The first and last operators in the timeseries_catalog schema is different from those in the public schema.
Precautions
If there are same minimum or maximum values in the cmp_col column, return the first or last value.
If the values in the cmp_col column are constants, the first and last operators equal those in the public schema, and the first or last value will be returned.
Syntax Format
select city_name,timeseries_catalog.first(temp_c,time) from weather_metrics group by city_name;
select city_name,timeseries_catalog.last(temp_c,time) from weather_metrics group by city_name;
timeseries_catalog.first(value, cmp_col)
timeseries_catalog.last(value, cmp_col)
Parameter Description
Parameter Name | Type | Mandatory or Not | Description |
---|---|---|---|
value | ANY | Yes | Used for returning values. |
cmp_col | TIMESTAMP or TIMESTAMPTZ | Yes | Used for value comparison. |
Examples
Uqbar=# select city_name,timeseries_catalog.first(temp_c,time) from weather_metrics group by city_name;
city_name | first
---------------+-------
beijing | 30
shanghai | 29
(2 row)