数据仓库服务 GAUSSDB(DWS)-函数和表达式:first(column1, column2)

时间:2024-07-13 11:25:01

first(column1, column2)

聚合函数。通过比较分组内column2列的值,找到其中的最小值,输出对应column1列的值。

表9 参数说明

参数名

类型

描述

Requried/Option

column1

bigint/text/double/numeric

最终的输出列。

Required

column2

timestamp/timestamptz/numeric

比较列。

Required

示例:复用time_fill表达式中的表定义和数据。

求按照scope_name分组,每个分组内按照时间排序最靠前的idle的值:

1
2
3
4
5
6
select first(idle, time_string) from dcs_cpu group by scope_name;
first
-------
1
3
(2 rows)
support.huaweicloud.com/IoT-devg830-dws/dws_14_00007.html