v2.0
- About Uqbar
- Release Note
- Uqbar Installation
- Uqbar Management
- Data Retention Policy
- Time-Series Table Management
- Time-Series Data Write
- Data Compression
- Data Deletion
- Data Query
- Continuous Aggregation
- Time-Series Views
- Cluster Management
- Backup and Restoration
- Security
- GUC Parameters
- SQL Syntax
- Third Party Tools Support
- Glossary
first()/last()
Function Description
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.
Syntax
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. |
Constraints
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.
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)