> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# aggregate_group_by

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/aggregate_group_by.rs#L83-L98)
pub async fn [aggregate\_group\_by](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/aggregate-group-by.md#method.aggregate_group_by)( \&self, table\_name: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), column\_names: [Vec](https://doc.rust-lang.org/1.98.1/alloc/vec/struct.Vec.html)\<[String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html)>, offset: [i64](https://doc.rust-lang.org/1.98.1/std/primitive.i64.html), limit: [i64](https://doc.rust-lang.org/1.98.1/std/primitive.i64.html), ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[AggregateGroupByResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.AggregateGroupByResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Calculate unique combinations of values for the given columns in a given datasetCalculates unique combinations (groups) of values for the given columns in a given table or view and computes aggregates on each unique combination. This is somewhat analogous to an SQL-style SELECT…GROUP BY.For aggregation details and examples, see Aggregation. For limitations, see Aggregation Limitations.Any column(s) can be grouped on, and all column types except unrestricted-length strings may be used for computing applicable aggregates.The results can be paged via the `offset` and `limit` parameters. For example, to get 10 groups with the largest counts the inputs would be: limit=10, options=\{“sort\_order”:“descending”, “sort\_by”:“value”}.`options` can be used to customize behavior of this call e.g. filtering or sorting the results.To group by columns ‘x’ and ‘y’ and compute the number of objects within each group, use: column\_names=\[‘x’,‘y’,‘count(\*)’].To also compute the sum of ‘z’ over each group, use: column\_names=\[‘x’,‘y’,‘count(\*)’,‘sum(z)’].Available aggregation functions are: count(\*), sum, min, max, avg, mean, stddev, stddev\_pop, stddev\_samp, var, var\_pop, var\_samp, arg\_min, arg\_max and count\_distinct.Available grouping functions are Rollup, Cube, and Grouping SetsThis service also provides support for Pivot operations.Filtering on aggregates is supported via expressions using aggregation functions supplied to having.The response is returned as a dynamic schema. For details see: dynamic schemas documentation.If a result\_table name is specified in the `options`, the results are stored in a new table with that name–no results are returned in the response. Both the table name and resulting column names must adhere to standard naming conventions; column/aggregation expressions will need to be aliased. If the source table’s shard key is used as the grouping column(s) and all result records are selected (`offset` is 0 and `limit` is -9999), the result table will be sharded, in all other cases it will be replicated. Sorting will properly function only if the result table is replicated or if there is only one processing node and should not be relied upon in other cases. Not available when any of the values of `column_names` is an unrestricted-length string.

##### Arguments

<ul>
  <li>`table_name` - Name of an existing table or view on which the operation will be performed, in \[schema\_name.]table\_name format, using standard name resolution rules.</li>
  <li>`column_names` - List of one or more column names, expressions, and aggregate expressions.</li>
  <li>`offset` - A positive integer indicating the number of initial results to skip (this can be useful for paging through the results).</li>
  <li>`limit` - A positive integer indicating the maximum number of results to be returned, or END\_OF\_SET (-9999) to indicate that the maximum number of results allowed by the server should be returned. The number of records returned will never exceed the server’s own limit, defined by the max\_get\_records\_size parameter in the server configuration. Use `has_more_records` to see if more records exist in the result to be fetched, and `offset` and `limit` to request subsequent pages of results.</li>
</ul>

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/aggregate_group_by.rs#L173-L198)
pub async fn [aggregate\_group\_by\_with\_opts](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/aggregate-group-by.md#method.aggregate_group_by_with_opts)( \&self, table\_name: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), column\_names: [Vec](https://doc.rust-lang.org/1.98.1/alloc/vec/struct.Vec.html)\<[String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html)>, offset: [i64](https://doc.rust-lang.org/1.98.1/std/primitive.i64.html), limit: [i64](https://doc.rust-lang.org/1.98.1/std/primitive.i64.html), options: [AggregateGroupByRequestOptions](https://docs.kinetica.com/content/api/rust/generated/api/struct.AggregateGroupByRequestOptions.md), ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[AggregateGroupByResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.AggregateGroupByResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Calculate unique combinations of values for the given columns in a given datasetCalculates unique combinations (groups) of values for the given columns in a given table or view and computes aggregates on each unique combination. This is somewhat analogous to an SQL-style SELECT…GROUP BY.For aggregation details and examples, see Aggregation. For limitations, see Aggregation Limitations.Any column(s) can be grouped on, and all column types except unrestricted-length strings may be used for computing applicable aggregates.The results can be paged via the `offset` and `limit` parameters. For example, to get 10 groups with the largest counts the inputs would be: limit=10, options=\{“sort\_order”:“descending”, “sort\_by”:“value”}.`options` can be used to customize behavior of this call e.g. filtering or sorting the results.To group by columns ‘x’ and ‘y’ and compute the number of objects within each group, use: column\_names=\[‘x’,‘y’,‘count(\*)’].To also compute the sum of ‘z’ over each group, use: column\_names=\[‘x’,‘y’,‘count(\*)’,‘sum(z)’].Available aggregation functions are: count(\*), sum, min, max, avg, mean, stddev, stddev\_pop, stddev\_samp, var, var\_pop, var\_samp, arg\_min, arg\_max and count\_distinct.Available grouping functions are Rollup, Cube, and Grouping SetsThis service also provides support for Pivot operations.Filtering on aggregates is supported via expressions using aggregation functions supplied to having.The response is returned as a dynamic schema. For details see: dynamic schemas documentation.If a result\_table name is specified in the `options`, the results are stored in a new table with that name–no results are returned in the response. Both the table name and resulting column names must adhere to standard naming conventions; column/aggregation expressions will need to be aliased. If the source table’s shard key is used as the grouping column(s) and all result records are selected (`offset` is 0 and `limit` is -9999), the result table will be sharded, in all other cases it will be replicated. Sorting will properly function only if the result table is replicated or if there is only one processing node and should not be relied upon in other cases. Not available when any of the values of `column_names` is an unrestricted-length string.

##### Arguments

<ul>
  <li>`table_name` - Name of an existing table or view on which the operation will be performed, in \[schema\_name.]table\_name format, using standard name resolution rules.</li>
  <li>`column_names` - List of one or more column names, expressions, and aggregate expressions.</li>
  <li>`offset` - A positive integer indicating the number of initial results to skip (this can be useful for paging through the results).</li>
  <li>`limit` - A positive integer indicating the maximum number of results to be returned, or END\_OF\_SET (-9999) to indicate that the maximum number of results allowed by the server should be returned. The number of records returned will never exceed the server’s own limit, defined by the max\_get\_records\_size parameter in the server configuration. Use `has_more_records` to see if more records exist in the result to be fetched, and `offset` and `limit` to request subsequent pages of results.</li>
  <li>`options` - The optional parameters; any left unset take the server’s defaults.</li>
</ul>

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/aggregate_group_by.rs#L202-L220)
pub async fn [aggregate\_group\_by\_request](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/aggregate-group-by.md#method.aggregate_group_by_request)( \&self, request: &[AggregateGroupByRequest](https://docs.kinetica.com/content/api/rust/generated/api/struct.AggregateGroupByRequest.md), ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[AggregateGroupByResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.AggregateGroupByResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Sends a pre-built [`AggregateGroupByRequest`](https://docs.kinetica.com/content/api/rust/generated/api/struct.AggregateGroupByRequest) to the `/aggregate/groupby` endpoint and decodes the records it returns. Only binary encoding is supported.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/aggregate_group_by.rs#L224-L235)
pub async fn [aggregate\_group\_by\_raw](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/aggregate-group-by.md#method.aggregate_group_by_raw)( \&self, request: &[AggregateGroupByRequest](https://docs.kinetica.com/content/api/rust/generated/api/struct.AggregateGroupByRequest.md), ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[RawAggregateGroupByResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.RawAggregateGroupByResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Sends a pre-built [`AggregateGroupByRequest`](https://docs.kinetica.com/content/api/rust/generated/api/struct.AggregateGroupByRequest) to the `/aggregate/groupby` endpoint, returning the response as the server sends it.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/aggregate_group_by.rs#L239-L251)
pub async fn [aggregate\_group\_by\_from\_url](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/aggregate-group-by.md#method.aggregate_group_by_from_url)( \&self, url: &[str](https://doc.rust-lang.org/1.98.1/std/primitive.str.html), request: &[AggregateGroupByRequest](https://docs.kinetica.com/content/api/rust/generated/api/struct.AggregateGroupByRequest.md), ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[RawAggregateGroupByResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.RawAggregateGroupByResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Sends a pre-built [`AggregateGroupByRequest`](https://docs.kinetica.com/content/api/rust/generated/api/struct.AggregateGroupByRequest) to a specific worker URL, bypassing HA head-node selection. Used for multi-head access.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.