diff desc online
This commit is contained in:
parent
f79841986b
commit
0a0de45f92
|
@ -1209,27 +1209,40 @@ ignore_negative: {
|
|||
### DIFF
|
||||
|
||||
```sql
|
||||
DIFF(expr [, ignore_negative])
|
||||
DIFF(expr [, ignore_option])
|
||||
|
||||
ignore_negative: {
|
||||
ignore_option: {
|
||||
0
|
||||
| 1
|
||||
| 2
|
||||
| 3
|
||||
}
|
||||
```
|
||||
|
||||
**Description**: The different of each row with its previous row for a specific column. `ignore_negative` can be specified as 0 or 1, the default value is 1 if it's not specified. `1` means negative values are ignored. For tables with composite primary key, the data with the smallest primary key value is used to calculate the difference.
|
||||
**Description**: The different of each row with its previous row for a specific column. `ignore_option` takes the value of 0|1|2|3, the default value is 0 if it's not specified.
|
||||
- `0` means that negative values (diff results) are not ignored and null values are not ignored
|
||||
- `1` means that negative values (diff results) are treated as null values
|
||||
- `2` means that negative values (diff results) are not ignored but null values are ignored
|
||||
- `3` means that negative values (diff results) are ignored and null values are ignored
|
||||
- For tables with composite primary key, the data with the smallest primary key value is used to calculate the difference.
|
||||
|
||||
**Return value type**:Same as the data type of the column being operated upon
|
||||
**Return value type**: `bool`, `timestamp` type and integer value type all return `int_64`, `floating` point type returns `double`, and if the diff result overflows, it is returned as overflow.
|
||||
|
||||
**Applicable data types**: Numeric
|
||||
**Applicable data types**: Numeric type, timestamp and bool type.
|
||||
|
||||
**Applicable table types**: standard tables and supertables
|
||||
|
||||
**More explanation**:
|
||||
|
||||
- The number of result rows is the number of rows subtracted by one, no output for the first row
|
||||
- It can be used together with a selected column. For example: select \_rowts, DIFF() from.
|
||||
|
||||
- diff is to diff the data in current row and column with the **first valid data before**. The **first valid data before** refers to sorting by timestamp, searching current this row to the direction of smaller timestamps, checking the same column of other rows, and finding the first non-null data.
|
||||
- The diff result of numeric type is the corresponding difference; the timestamp is calculated based on the timestamp of the precision type of the database creation; the difference is calculated for bool type true as 1 and false as 0
|
||||
- When the row and column data does not exist (null), or no valid comparison data is found, the diff result is null
|
||||
- When ignoring negative values (ignore_option is 1/3), if the diff result is negative, the result is set to null, and then filtered according to the null value filtering rule
|
||||
- When the diff result has a type overflow, the positive and negative results of the logical operation are used to determine whether to ignore the negative value. For example, the value of 9223372036854775800 - (-9223372036854775806) exceeds the range of BIGINT, and the diff result will display the overflow value -10, but it will not be ignored as a negative value
|
||||
- Supports single or multiple diffs in a single statement, and supports different diff functions to specify the same or different ignore_option , when there are multiple diffs, only when all diff results of a row are null and ignore_option is set to ignore null values, the row will be removed from the result set
|
||||
- Can be used with the selected associated columns. For example: select _rowts, DIFF() from.
|
||||
- When not using a composite primary key, the sub-tables of the super table may have the same timestamp data. If there are the same timestamps, it will prompt "Duplicate timestamps not allowed"
|
||||
- When using a composite primary key, the sub-tables of the super table may have the same composite primary key, whichever row is found first will prevail
|
||||
|
||||
### IRATE
|
||||
|
||||
|
|
|
@ -1200,27 +1200,40 @@ ignore_negative: {
|
|||
### DIFF
|
||||
|
||||
```sql
|
||||
DIFF(expr [, ignore_negative])
|
||||
DIFF(expr [, ignore_option])
|
||||
|
||||
ignore_negative: {
|
||||
ignore_option: {
|
||||
0
|
||||
| 1
|
||||
| 2
|
||||
| 3
|
||||
}
|
||||
```
|
||||
|
||||
**功能说明**:统计表中某列的值与前一行对应值的差。 ignore_negative 取值为 0|1 , 可以不填,默认值为 0. 不忽略负值。ignore_negative 为 1 时表示忽略负数。对于你存在复合主键的表的查询,若时间戳相同的数据存在多条,则只有对应的复合主键最小的数据参与运算。
|
||||
**功能说明**:统计表中某列的值与之前行有效值的差。 ignore_option 取值为 0|1|2|3 , 可以不填,默认值为 0.
|
||||
- 为 0 表示不忽略(diff结果)负值不忽略 null 值
|
||||
- 为 1 时则表示(diff结果)负值作为 null 值
|
||||
- 为 2 表示不忽略(diff结果)负值但忽略 null 值
|
||||
- 为 3 时则表示忽略(diff结果)负值且忽略 null 值
|
||||
- 对于存在复合主键的表的查询,若时间戳相同的数据存在多条,则只有对应的复合主键最小的数据参与运算。
|
||||
|
||||
**返回数据类型**:同应用字段。
|
||||
**返回数据类型**:bool、时间戳类型及整型数值类型均返回 int_64,浮点类型返回 double, 若 diff 结果溢出则按溢出返回。
|
||||
|
||||
**适用数据类型**:数值类型。
|
||||
**适用数据类型**:数值类型、时间戳和 bool 类型。
|
||||
|
||||
**适用于**:表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
|
||||
- 输出结果行数是范围内总行数减一,第一行没有结果输出。
|
||||
- 可以与选择相关联的列一起使用。 例如: select \_rowts, DIFF() from。
|
||||
|
||||
- diff 是本行本列数据和之前最近的第一个有效数据做 diff,之前最近的第一个有效数据:指的是按照时间戳排序,从本行向较小的时间戳方向寻找,查看其他行的同一列,寻找到的第一个非 null 数据。
|
||||
- 数值类型 diff 结果为对应差值;时间戳根据创建数据库的精度类型的时间戳进行差值计算;bool 型 true 为1, false 为 0 进行差值计算
|
||||
- 当本行列数据不存在(为 null )时,或者没找到有效的比较数据,diff 结果为 null
|
||||
- 忽略负值时( ignore_option 为 1 / 3 ),如果 diff 结果为负值,则结果设置为 null, 然后根据 null 值过滤规则过滤
|
||||
- 当 diff 结果有类型溢出时,根据逻辑运算结果的正负进行判定是否忽略负值,例如 9223372036854775800 - (-9223372036854775806) 的值超出 BIGINT 的范围 ,diff 结果会显示溢出值 -10,但并不会被作为负值忽略
|
||||
- 支持单个语句中同时存在单个或者多个 diff,支持不同的 diff 函数指定相同或不同的 ignore_option ,当存在多个 diff 时只有当某行所有 diff 结果都为 null 且 ignore_option 都设置了忽略 null 值,该行才从结果集中剔除
|
||||
- 可以与选择相关联的列一起使用。 例如: select _rowts, DIFF() from。
|
||||
- 不使用复合主键时,超级表的子表可能会有相同时间戳数据,有相同的时间戳时,会提示 "Duplicate timestamps not allowed"
|
||||
- 使用复合主键时,超级表的子表可能有相同的复合主键,以首先找到的行数据为准
|
||||
|
||||
### IRATE
|
||||
|
||||
|
|
Loading…
Reference in New Issue