fix: add more detail description about partition by clause
This commit is contained in:
parent
cedfff1cb0
commit
fceaedce22
|
@ -259,7 +259,11 @@ The GROUP BY clause does not guarantee that the results are ordered. If you want
|
||||||
|
|
||||||
## PARTITION BY
|
## PARTITION BY
|
||||||
|
|
||||||
The PARTITION BY clause is a TDengine-specific extension to standard SQL. This clause partitions data based on the part_list and performs computations per partition.
|
The PARTITION BY clause is a TDengine-specific extension to standard SQL introduced in TDengine 3.0. This clause partitions data based on the part_list and performs computations per partition.
|
||||||
|
|
||||||
|
PARTITION BY and GROUP BY have similar meanings. They both group data according to a specified list and then perform calculations. The difference is that PARTITION BY does not have various restrictions on the SELECT list of the GROUP BY clause. Any operation can be performed within the group (constants, aggregations, scalars, expressions, etc.). Therefore, PARTITION BY is fully compatible with GROUP BY in terms of usage. All places that use the GROUP BY clause can be replaced with PARTITION BY.
|
||||||
|
|
||||||
|
Because PARTITION BY does not require returning a row of aggregated data, it can also support various window operations after grouping slices. All window operations that need to be grouped can only use the PARTITION BY clause.
|
||||||
|
|
||||||
For more information, see TDengine Extensions.
|
For more information, see TDengine Extensions.
|
||||||
|
|
||||||
|
|
|
@ -259,7 +259,12 @@ GROUP BY 子句中的表达式可以包含表或视图中的任何列,这些
|
||||||
|
|
||||||
## PARTITION BY
|
## PARTITION BY
|
||||||
|
|
||||||
PARTITION BY 子句是 TDengine 特色语法,按 part_list 对数据进行切分,在每个切分的分片中进行计算。
|
PARTITION BY 子句是 TDengine 3.0版本引入的特色语法,用于根据 part_list 对数据进行切分,在每个切分的分片中可以进行各种计算。
|
||||||
|
|
||||||
|
PARTITION BY 与 GROUP BY 基本含义相似,都是按照指定列表进行数据分组然后进行计算,不同点在于 PARTITION BY 没有 GROUP BY 子句的 SELECT 列表的各种限制,组内可以进行任意运算(常量、聚合、标量、表达式等),因此在使用上 PARTITION BY 完全兼容 GROUP BY,所有使用 GROUP BY 子句的地方都可以替换为 PARTITION BY。
|
||||||
|
|
||||||
|
因为 PARTITION BY 没有返回一行聚合数据的要求,因此还可以支持在分组切片后的各种窗口运算,所有需要分组进行的窗口运算都只能使用 PARTITION BY 子句。
|
||||||
|
|
||||||
|
|
||||||
详见 [TDengine 特色查询](../distinguished)
|
详见 [TDengine 特色查询](../distinguished)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue