cols desc

This commit is contained in:
facetosea 2025-02-21 11:05:08 +08:00
parent 450d262415
commit 29b7b27e53
2 changed files with 41 additions and 0 deletions

View File

@ -2125,6 +2125,27 @@ UNIQUE(expr)
**Applicable to**: Tables and supertables.
### COLS
```sql
COLS(select_function(expr), output_expr1, [, output_expr2] ... )
```
**Function Description**: On the data row where the execution result of function func (expr) is located, execute the expression output_expr1, [, output_expr2], return its result, and the result of func (expr) is not output.
**Return Data Type**: Returns multiple columns of data, and the data type of each column is the type of the result returned by the corresponding expression.
**Applicable Data Types**: All type fields.
**Applicable to**: Tables and Super Tables.
**Usage Instructions**:
- Func function type: must be a single-line selection function (output result is a single-line selection function, for example, last is a single-line selection function, but top is a multi-line selection function).
- The result of the parameter func is not returned. If you want to output the result of func, you need to add the corresponding output_expr parameter to the letter.
- When there is only one column in the output, you can set an alias for the function. For example, you can do it like this: "select cols(first (ts), c1) as c11 from ...".
- Output one or more columns, and you can set an alias for each output column of the function. For example, you can do it like this: "select (first (ts), c1 as c11, c2 as c22) from ...".
## Time-Series Specific Functions
Time-Series specific functions are tailor-made by TDengine to meet the query scenarios of time-series data. In general databases, implementing similar functionalities usually requires complex query syntax and is inefficient. TDengine has built these functionalities into functions, greatly reducing the user's cost of use.

View File

@ -2051,6 +2051,26 @@ UNIQUE(expr)
**适用于**: 表和超级表。
### COLS
```sql
COLS(select_function(expr), output_expr1, [, output_expr2] ... )
```
**功能说明**:在选择函数 func(expr) 执行结果所在数据行上,执行表达式 output_expr1, [,output_expr2]返回其结果func(expr)结果不输出.
**返回数据类型**:返回多列数据,每列数据类型为对应表达式返回结果的类型。
**适用数据类型**:全部类型字段。
**适用于**:表和超级表。
**使用说明:**
- func 函数类型:必须是单行选择函数(输出结果为一行的选择函数,例如 last 是单行选择函数, 但 top 是多行选择函数)。
- 注意, 参数 func 的结果并没有返回,如需输出 func 结果,需要在 cols 中加上相应的 output_expr 参数。
- 输出只有一列时,可以对 cols 函数设置别名。例如: "select cols(first(ts), c1) as c11 from ..."
- 输出一列或者多列,可以对 cols 函数的每个输出列设置命名。例如: "select cols(first(ts), c1 as c11, c2 as c22)"
## 时序数据特有函数