Skip to content

Commit 630c3ea

Browse files
authored
Add docs for GROUP BY ALL and ORDER BY ALL (#1120)
* Add docs for `GROUP BY ALL` and `ORDER BY ALL` * tweak wording * tweak wording
1 parent d80f5a2 commit 630c3ea

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

website/docs/reference/sql/select.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,16 @@ Example:
198198
SELECT a, b, ARRAY_AGG(c, ORDER BY d) FROM table GROUP BY a, b
199199
```
200200

201+
#### `GROUP BY ALL`
202+
203+
Use GROUP BY ALL to group by every column in the SELECT list that isn’t inside an aggregate function. This keeps the column definitions in one place, simplifies the query, and prevents bugs by keeping the SELECT granularity aligned with the GROUP BY granularity (e.g., preventing unintended duplication).
204+
205+
Example:
206+
207+
```sql
208+
SELECT a, b, MAX(c) FROM table GROUP BY ALL
209+
```
210+
201211
### HAVING clause
202212

203213
The `HAVING` clause can be used with `GROUP BY` to eliminate groups that don't satisfy the condition given.
@@ -242,6 +252,14 @@ SELECT age, person FROM table ORDER BY age DESC;
242252
SELECT age, person FROM table ORDER BY age, person DESC;
243253
```
244254

255+
#### `ORDER BY ALL`
256+
257+
Order from left to right (by age, then by person) in ascending order:
258+
259+
```sql
260+
SELECT age, person FROM table ORDER BY ALL;
261+
```
262+
245263
### LIMIT clause
246264

247265
Limits the number of rows to be a maximum of `count` rows. `count` should be a non-negative integer.

0 commit comments

Comments
 (0)