diff --git a/documentation20/cn/12.taos-sql/docs.md b/documentation20/cn/12.taos-sql/docs.md index 7790d7f49e5184c31c5e8ad7d0006fedcd59d1a6..1cc4a542ce7be066fa4417ad6536af17f7d87d8c 100755 --- a/documentation20/cn/12.taos-sql/docs.md +++ b/documentation20/cn/12.taos-sql/docs.md @@ -1776,6 +1776,59 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 功能说明:获得指定列的四舍五入的结果。 其他使用说明参见CEIL函数描述。 +- **CSUM** + ```sql + SELECT CSUM(field_name) FROM { tb_name | stb_name } [WHERE clause] + ``` + + 功能说明:累加和(Cumulative sum),输出行与输入行数相同。 + + 返回结果类型: 输入列如果是整数类型返回值为长整型 (int64_t),浮点数返回值为双精度浮点数(Double)。无符号整数类型返回值为无符号长整型(uint64_t)。 返回结果中同时带有每行记录对应的时间戳。 + + 适用数据类型:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在标签之上。 + + 嵌套子查询支持: 适用于内层查询和外层查询。 + + 补充说明: 不支持 +、-、*、/ 运算,如 csum(col1) + csum(col2)。只能与聚合(Aggregation)函数一起使用。 该函数可以应用在普通表和超级表上。 使用在超级表上的时候,需要搭配 Group by tbname使用,将结果强制规约到单个时间线。 + + 支持版本: 从2.3.0.x开始支持 + +- **MAVG** + ```sql + SELECT MAVG(field_name, K) FROM { tb_name | stb_name } [WHERE clause] + ``` + + 功能说明: 计算连续 k 个值的移动平均数(moving average)。如果输入行数小于 k,则无结果输出。参数 k 的合法输入范围是 1≤ k ≤ 1000。 + + 返回结果类型: 返回双精度浮点数类型。 + + 适用数据类型: 不能应用在 timestamp、binary、nchar、bool 类型上;在超级表查询中使用时,不能应用在标签之上。 + + 嵌套子查询支持: 适用于内层查询和外层查询。 + + 补充说明: 不支持 +、-、*、/ 运算,如 mavg(col1, k1) + mavg(col2, k1); 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用;该函数可以应用在普通表和超级表上;使用在超级表上的时候,需要搭配 Group by tbname使用,将结果强制规约到单个时间线。 + + 支持版本: 从2.3.0.x开始支持 + +- **SAMPLE** + ```sql + SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] + ``` + + 功能说明: 获取数据的 k 个采样值。参数 k 的合法输入范围是 1≤ k ≤ 1000。 + + 返回结果类型: 同原始数据类型, 返回结果中带有该行记录的时间戳。 + + 适用数据类型: 在超级表查询中使用时,不能应用在标签之上。 + + 嵌套子查询支持: 适用于内层查询和外层查询。 + + 补充说明: 不能参与表达式计算;该函数可以应用在普通表和超级表上;使用在超级表上的时候,需要搭配 Group by tbname 使用,将结果强制规约到单个时间线。 + + 支持版本: 从2.3.0.x开始支持 + + + - **ASIN** ```mysql SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] diff --git a/documentation20/en/12.taos-sql/docs.md b/documentation20/en/12.taos-sql/docs.md index b6ed11c7cf401b8a234f7f1d06a90ed61dc8e9b9..137dfe9123fe817307bd2414e4d81dd305aba2d8 100755 --- a/documentation20/en/12.taos-sql/docs.md +++ b/documentation20/en/12.taos-sql/docs.md @@ -1304,6 +1304,62 @@ TDengine supports aggregations over data, they are listed below: Query OK, 1 row(s) in set (0.000836s) ``` +- **CSUM** + ```sql + SELECT CSUM(field_name) FROM { tb_name | stb_name } [WHERE clause] + ``` + + Function: Cumulative sum computes the running total of one time series. It occurs in select clause of SQL statement. + + Input: Input column data type should be a numeric type. + + Output: If the input data type is unsigned int type, the result data type is uint64_t. If the input data type is signed int type, the result data type is int64_t. If the input data type is float or double, the result data type is double. The function also outputs the timestamp of the current row. + + Table: The csum function only applies to the normal table, child table, and super table with group by tbname. + + Nested Query: The csum function applies to both outer query and nested query. + + Note: Can't be used with +-*/ arithmatic operations,like csum(col1) + csum(col2), can only be used with aggragation functions. + +- **MAVG** + ```sql + SELECT MAVG(field_name, K) FROM { tb_name | stb_name } [WHERE clause] + ``` + + Function: Moving Average Function Computes the rolling simple average over k values of one time series. It occurs in select clause of SQL statement. If the input time series has less than k values, no result is calculated. + + Input: Input column data should be a numeric type. + + Output: The Result data type is double. The function also outputs the timestamp of the current row. + + Parameter: K is an integer between 1 and 1000. + + Table: The mavg function only applies to the normal table, child table, and super table with group by tbname. + + Nested Query: The mavg function applies to both outer query and nested query. + + Note: Can't be used with +-*/ arithmatic operations, like mavg(col1, k1) + mavg(col2, k1); can only be used with normal columns, selection and projection functions,can't be used with aggragation functions. + +- **SAMPLE** + ``` + SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] + ``` + + Function: Sample function samples k values from a specific time series with equal probability. It occurs in select clause of SQL statement + + Input: There are no restrictions on the input data type. + + Output: The output data type is the same as the input data type. The function also outputs the timestamp of the current row. + + Parameter: K is an integer between 1 and 1000. + + Table: he sample function only applies to the normal table, child table, and super table with group by tbname. + + Nested Query: The sample function applies to both outer query and nested query. + + Note: Can't be used as operand in an expression + + - **ASIN** ```mysql SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause]