> ## 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_statistics

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/aggregate_statistics.rs#L61-L74)
pub async fn [aggregate\_statistics](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/aggregate-statistics.md#method.aggregate_statistics)( \&self, table\_name: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), column\_name: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), stats: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[AggregateStatisticsResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.AggregateStatisticsResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Calculate statistics of a datasetCalculates the requested statistics of the given column(s) in a given table.The available statistics are: count (number of total objects), mean, stdv (standard deviation), variance, skew, kurtosis, sum, min, max, weighted\_average, cardinality (unique count), estimated\_cardinality, percentile, and percentile\_rank.Estimated cardinality is calculated by using the hyperloglog approximation technique.Percentiles and percentile ranks are approximate and are calculated using the t-digest algorithm. They must include the desired percentile/percentile\_rank. To compute multiple percentiles each value must be specified separately (i.e. ‘percentile(75.0),percentile(99.0),percentile\_rank(1234.56),percentile\_rank(-5)’).A second, comma-separated value can be added to the percentile statistic to calculate percentile resolution, e.g., a 50th percentile with 200 resolution would be ‘percentile(50,200)’.The weighted average statistic requires a weight column to be specified in weight\_column\_name. The weighted average is then defined as the sum of the products of `column_name` times the weight\_column\_name values divided by the sum of the weight\_column\_name values.Additional columns can be used in the calculation of statistics via additional\_column\_names. Values in these columns will be included in the overall aggregate calculation–individual aggregates will not be calculated per additional column. For instance, requesting the count and mean of `column_name` x and additional\_column\_names y and z, where x holds the numbers 1-10, y holds 11-20, and z holds 21-30, would return the total number of x, y, and z values (30), and the single average value across all x, y, and z values (15.5).The response includes a list of key/value pairs of each statistic requested and its corresponding value.

##### Arguments

<ul>
  <li>`table_name` - Name of the table on which the statistics operation will be performed, in \[schema\_name.]table\_name format, using standard name resolution rules.</li>
  <li>`column_name` - Name of the primary column for which the statistics are to be calculated.</li>
  <li>`stats` - Comma separated list of the statistics to calculate, e.g. “sum,mean”.</li>
</ul>

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/aggregate_statistics.rs#L127-L147)
pub async fn [aggregate\_statistics\_with\_opts](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/aggregate-statistics.md#method.aggregate_statistics_with_opts)( \&self, table\_name: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), column\_name: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), stats: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), options: [AggregateStatisticsRequestOptions](https://docs.kinetica.com/content/api/rust/generated/api/struct.AggregateStatisticsRequestOptions.md), ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[AggregateStatisticsResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.AggregateStatisticsResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Calculate statistics of a datasetCalculates the requested statistics of the given column(s) in a given table.The available statistics are: count (number of total objects), mean, stdv (standard deviation), variance, skew, kurtosis, sum, min, max, weighted\_average, cardinality (unique count), estimated\_cardinality, percentile, and percentile\_rank.Estimated cardinality is calculated by using the hyperloglog approximation technique.Percentiles and percentile ranks are approximate and are calculated using the t-digest algorithm. They must include the desired percentile/percentile\_rank. To compute multiple percentiles each value must be specified separately (i.e. ‘percentile(75.0),percentile(99.0),percentile\_rank(1234.56),percentile\_rank(-5)’).A second, comma-separated value can be added to the percentile statistic to calculate percentile resolution, e.g., a 50th percentile with 200 resolution would be ‘percentile(50,200)’.The weighted average statistic requires a weight column to be specified in weight\_column\_name. The weighted average is then defined as the sum of the products of `column_name` times the weight\_column\_name values divided by the sum of the weight\_column\_name values.Additional columns can be used in the calculation of statistics via additional\_column\_names. Values in these columns will be included in the overall aggregate calculation–individual aggregates will not be calculated per additional column. For instance, requesting the count and mean of `column_name` x and additional\_column\_names y and z, where x holds the numbers 1-10, y holds 11-20, and z holds 21-30, would return the total number of x, y, and z values (30), and the single average value across all x, y, and z values (15.5).The response includes a list of key/value pairs of each statistic requested and its corresponding value.

##### Arguments

<ul>
  <li>`table_name` - Name of the table on which the statistics operation will be performed, in \[schema\_name.]table\_name format, using standard name resolution rules.</li>
  <li>`column_name` - Name of the primary column for which the statistics are to be calculated.</li>
  <li>`stats` - Comma separated list of the statistics to calculate, e.g. “sum,mean”.</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_statistics.rs#L150-L161)
pub async fn [aggregate\_statistics\_raw](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/aggregate-statistics.md#method.aggregate_statistics_raw)( \&self, request: &[AggregateStatisticsRequest](https://docs.kinetica.com/content/api/rust/generated/api/struct.AggregateStatisticsRequest.md), ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[AggregateStatisticsResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.AggregateStatisticsResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Sends a pre-built [`AggregateStatisticsRequest`](https://docs.kinetica.com/content/api/rust/generated/api/struct.AggregateStatisticsRequest) to the `/aggregate/statistics` endpoint.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/aggregate_statistics.rs#L165-L177)
pub async fn [aggregate\_statistics\_from\_url](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/aggregate-statistics.md#method.aggregate_statistics_from_url)( \&self, url: &[str](https://doc.rust-lang.org/1.98.1/std/primitive.str.html), request: &[AggregateStatisticsRequest](https://docs.kinetica.com/content/api/rust/generated/api/struct.AggregateStatisticsRequest.md), ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[AggregateStatisticsResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.AggregateStatisticsResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Sends a pre-built [`AggregateStatisticsRequest`](https://docs.kinetica.com/content/api/rust/generated/api/struct.AggregateStatisticsRequest) 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.