Skip to content

Commit 9e59448

Browse files
committed
Document GROUP BY AUTO syntax
1 parent aa873bb commit 9e59448

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

docs/src/main/sphinx/sql/select.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,30 @@ Complex grouping operations are often equivalent to a `UNION ALL` of simple
379379
does not apply, however, when the source of data for the aggregation
380380
is non-deterministic.
381381

382+
### AUTO
383+
384+
`AUTO` syntax implicitly groups on every column not included in an aggregation
385+
function.
386+
387+
This query sums the account balance (`acctbal`) for each market segment
388+
(`mktsegment`), with `AUTO` automatically determining the grouping
389+
keys:
390+
391+
```sql
392+
SELECT mktsegment, sum(acctbal) FROM shipping GROUP BY AUTO;
393+
```
394+
395+
```text
396+
mktsegment | _col1
397+
------------+--------------------
398+
BUILDING | 1444587.8
399+
MACHINERY | 1296958.61
400+
HOUSEHOLD | 1279340.66
401+
FURNITURE | 1265282.8
402+
AUTOMOBILE | 1395695.7200000004
403+
(5 rows)
404+
```
405+
382406
### GROUPING SETS
383407

384408
Grouping sets allow users to specify multiple lists of columns to group on.

0 commit comments

Comments
 (0)