File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -379,6 +379,32 @@ Complex grouping operations are often equivalent to a `UNION ALL` of simple
379379does not apply, however, when the source of data for the aggregation
380380is non-deterministic.
381381
382+ ### AUTO
383+
384+ When ` AUTO ` is specified, the Trino engine automatically determines the grouping
385+ columns instead of requiring them to be listed explicitly. In this mode, any
386+ column in the ` SELECT ` list that is not part of an aggregate function is
387+ implicitly treated as a grouping column.
388+
389+ This example query calculates the total account balance per market segment.
390+ The ` AUTO ` clause derives ` mktsegment ` as the grouping key, since it is not used
391+ in any aggregate function (i.e., ` sum ` ).
392+
393+ ``` sql
394+ SELECT mktsegment, sum (acctbal) FROM shipping GROUP BY AUTO;
395+ ```
396+
397+ ``` text
398+ mktsegment | _col1
399+ ------------+--------------------
400+ BUILDING | 1444587.8
401+ MACHINERY | 1296958.61
402+ HOUSEHOLD | 1279340.66
403+ FURNITURE | 1265282.8
404+ AUTOMOBILE | 1395695.7200000004
405+ (5 rows)
406+ ```
407+
382408### GROUPING SETS
383409
384410Grouping sets allow users to specify multiple lists of columns to group on.
You can’t perform that action at this time.
0 commit comments