DB_Table.aggregate
aggregategroup_by columns error_on_missing_columns on_problems
Group: Calculations
Aliases: average, count, count distinct, first, group by, last, longest, maximum, mean, median, minimum, mode, percentile, shortest, standard deviation, sum, summarize, variance
Documentation
Aggregates the rows in a table using group_by columns. The columns argument specifies which additional aggregations to perform and to return.
Arguments
group_by: Vector of column identifiers to group by. These will be included at the start of the resulting table. If no columns are specified a single row will be returned with the aggregate columns.columns: Vector ofAggregate_Columnspecifying the aggregated table. Expressions can be used within the aggregate column to perform more complicated calculations.error_on_missing_columns: Specifies if a missing columns in aggregates should result in an error regardless of theon_problemssettings. Defaults toFalse, meaning that problematic aggregate will not be included in the result and the problem reported according to theon_problemssetting.on_problems: Specifies how to handle problems if they occur, reporting them as warnings by default.
Examples
Count all the rows
table.aggregate columns=[Aggregate_Column.Count]
Group by the Key column, count the rows
table.aggregate ["Key"] [Aggregate_Column.Count]
Errors
- If there are no columns in the output table, a
No_Output_Columnsis raised as an error regardless of the problem behavior, because it is not possible to create a table without any columns. - If a given aggregate is not supported by the backend,
Unsupported_Database_Operationis reported. - If a column index is out of range, a
Missing_Input_Columnsis reported according to theon_problemssetting, unlesserror_on_missing_columnsis set toTrue, in which case it is raised as an error. Problems resolvinggroup_bycolumns are reported as dataflow errors regardless of these settings, as a missing grouping will completely change semantics of the query. - If a column selector is given as a
Textand it does not match any columns in the input table nor is it a valid expression, anInvalid_Aggregate_Columnerror is raised according to theon_problemssettings (unlesserror_on_missing_columnsis set toTruein which case it will always be an error). Problems resolvinggroup_bycolumns are reported as dataflow errors regardless of these settings, as a missing grouping will completely change semantics of the query. - If an aggregation fails, an
Invalid_Aggregationdataflow error is raised. - The following additional problems may be reported according to the
on_problemssettings:- If there are invalid column names in the output table,
a
Invalid_Column_Names. - If there are duplicate column names in the output table,
a
Duplicate_Output_Column_Names. - If grouping on or computing the
Modeon a floating point number, aFloating_Point_Equality. - If when concatenating values there is an quoted delimited,
an
Unquoted_Delimiter - If there are more than 10 issues with a single column,
an
Additional_Warnings.
- If there are invalid column names in the output table,
a