docs for GROUP BY ALL

This commit is contained in:
taofengliu 2022-10-13 01:54:04 +08:00
parent 46739eeaf8
commit 17be6ab492
2 changed files with 52 additions and 0 deletions

View File

@ -243,6 +243,32 @@ If `max_rows_to_group_by` and `group_by_overflow_mode = 'any'` are not used, all
You can use `WITH TOTALS` in subqueries, including subqueries in the [JOIN](../../../sql-reference/statements/select/join.md) clause (in this case, the respective total values are combined).
## GROUP BY ALL
`GROUP BY ALL` is equivalent to listing all the SELECT-ed columns that are not expressions of the aggregate functions.
For example:
``` sql
SELECT
a,
b,
count(c),
FROM t
GROUP BY ALL
```
is the same as
``` sql
SELECT
a,
b,
count(c),
FROM t
GROUP BY a, b
```
## Examples
Example:

View File

@ -77,6 +77,32 @@ sidebar_label: GROUP BY
您可以使用 `WITH TOTALS` 在子查询中,包括在子查询 [JOIN](../../../sql-reference/statements/select/join.md) 子句(在这种情况下,将各自的总值合并)。
## GROUP BY ALL {#group-by-all}
`GROUP BY ALL` 相当于对所有被查询的并且不被聚合函数使用的列进行 `GROUP BY`
例如
``` sql
SELECT
a,
b,
count(c),
FROM t
GROUP BY ALL
```
效果等同于
``` sql
SELECT
a,
b,
count(c),
FROM t
GROUP BY a, b
```
## 例子 {#examples}
示例: