FUNCTION窗口函数
first_value
返回在窗口帧的第一行求得的 value。
Returns value evaluated at the row that is the first row of the window frame.
窗口函数 引入 8.4 现存至 20 devel 1 条签名 1 次签名变更
- 分组
- 窗口函数
- 签名数
- 1 条
- 引入版本
- 8.4
- 状态
- 现存
- 签名变更
- 1 次
- 本版来源
- 同版手册译文
版本轨迹
相对 PostgreSQL 17 无变化。
说明
value。first_value ( value anyelement ) → anyelement返回在窗口帧的第一行求得的
value。签名
PostgreSQL 18.7 里 first_value 的 1 条签名,按上游手册顺序排列。参数名用斜体,类型用弱化色, 之后是返回类型。中文说明来自同版本手册与审阅译文,悬停可查看每条说明的来源。
-
first_value(valueanyelement) →anyelement返回在窗口帧的第一行求得的value。
演化历史
相邻两个大版本之间的差异,新的在前。版本号链到该版的签名。
-
PostgreSQL 19 ← 18 签名变更
first_value ( value anyelement ) [ null treatment ] → anyelementfirst_value ( value anyelement ) → anyelement -
PostgreSQL 13 ← 12 手册重排
这一跳手册重排了函数表的写法,签名文本整体改写,只记函数的增删,不逐条比较签名。
-
PostgreSQL 8.4 ← 8.3 新增此函数
PostgreSQL 8.4 起可用
签名矩阵
每条签名在给出了签名的 19 个版本里的存在情况;方格指向该版的签名。只在正文里提到此函数、没有给出签名的版本不列进来,上面的版本轨迹里仍然有它们。签名文本在 PostgreSQL 13 前后写法不同,跨越那一跳的同一条签名会显示成两行。
存在 不存在
| 签名 | 8.4 | 9.0 | 9.1 | 9.2 | 9.3 | 9.4 | 9.5 | 9.6 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
first_value ( value any ) → same type as value |
存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 |
first_value ( value anyelement ) → anyelement |
不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 存在 | 不存在 | 不存在 |
first_value ( value anyelement ) [ null treatment ] → anyelement |
不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 存在 | 存在 |
同组函数
| 函数 | 签名 | 主签名 | 版本变动 | 最近变更 |
|---|---|---|---|---|
first_value |
1 | first_value ( value anyelement ) [ null treatment ] → anyelement |
191 次 | |
| 返回在窗口帧的第一行求得的 value。 | 现存 | |||
lag |
1 | lag ( value anycompatible [, offset integer [, default anycompatible ]] ) [ null treatment ] → anycompatible |
193 次 | |
| 返回在分区内当前行之前 offset 行处计算的 value;如果没有这样的行,则返回 default(其类型必须与 value 兼容)。offset 和 default 都针对当前行求值。如果省略,offset 默认为 1,default 默认为 NULL。 | 现存 | |||
last_value |
1 | last_value ( value anyelement ) [ null treatment ] → anyelement |
191 次 | |
| 返回在窗口帧的最后一行求得的 value。 | 现存 | |||
lead |
1 | lead ( value anycompatible [, offset integer [, default anycompatible ]] ) [ null treatment ] → anycompatible |
193 次 | |
| 返回在分区内当前行之后 offset 行处计算的 value;如果没有这样的行,则返回 default(其类型必须与 value 兼容)。offset 和 default 都针对当前行求值。如果省略,offset 默认为 1,default 默认为 NULL。 | 现存 | |||
nth_value |
1 | nth_value ( value anyelement, n integer ) [ null treatment ] → anyelement |
191 次 | |
| 返回在窗口帧的第 n 行求得的 value(从 1 开始计数);如果没有这样的行,则返回 NULL。 | 现存 | |||
ntile |
1 | ntile ( num_buckets integer ) → integer |
— | |
| 返回从 1 到参数值的整数,将分区尽可能均等地划分。 | 现存 | |||
row_number |
1 | row_number () → bigint |
— | |
| 返回当前行在其分区内的编号,从 1 开始计数。 | 现存 | |||