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

# aggregateStatistics

<div className="kinetica-javadoc">
  <ul className="member-list">
    <li>
      <div className="section detail" id="aggregateStatistics(com.gpudb.protocol.AggregateStatisticsRequest)">
        <h3>aggregateStatistics</h3>
        <div className="member-signature"><span className="modifiers">public</span> <span className="return-type"><a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsResponse" title="class in com.gpudb.protocol">AggregateStatisticsResponse</a></span> <span className="element-name">aggregateStatistics</span><wbr /><span className="parameters">(<a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest" title="class in com.gpudb.protocol">AggregateStatisticsRequest</a> request)</span> throws <span className="exceptions"><a href="/content/api/java/com/gpudb/GPUdbException" title="class in com.gpudb">GPUdbException</a></span></div>

        <div className="block">
          Calculates the requested statistics of the given column(s) in a given table.
          <p> The available statistics are: <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#COUNT"><code>COUNT</code></a> (number of total objects), <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#MEAN"><code>MEAN</code></a>, <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#STDV"><code>STDV</code></a> (standard deviation), <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#VARIANCE"><code>VARIANCE</code></a>, <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#SKEW"><code>SKEW</code></a>, <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#KURTOSIS"><code>KURTOSIS</code></a>, <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#SUM"><code>SUM</code></a>, <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#MIN"><code>MIN</code></a>, <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#MAX"><code>MAX</code></a>, <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#WEIGHTED_AVERAGE"><code>WEIGHTED\_AVERAGE</code></a>, <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#CARDINALITY"><code>CARDINALITY</code></a> (unique count), <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#ESTIMATED_CARDINALITY"><code>ESTIMATED\_CARDINALITY</code></a>, <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#PERCENTILE"><code>PERCENTILE</code></a>, and <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#PERCENTILE_RANK"><code>PERCENTILE\_RANK</code></a>. </p>
          <p> Estimated cardinality is calculated by using the hyperloglog approximation technique. </p>
          <p> Percentiles and percentile ranks are approximate and are calculated using the t-digest algorithm. They must include the desired <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#PERCENTILE"><code>PERCENTILE</code></a>/<a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#PERCENTILE_RANK"><code>PERCENTILE\_RANK</code></a>. 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)'). </p>
          <p> A second, comma-separated value can be added to the <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#PERCENTILE"><code>PERCENTILE</code></a> statistic to calculate percentile resolution, e.g., a 50th percentile with 200 resolution would be 'percentile(50,200)'. </p>
          <p> The weighted average statistic requires a weight column to be specified in <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Options#WEIGHT_COLUMN_NAME"><code>WEIGHT\_COLUMN\_NAME</code></a>. The weighted average is then defined as the sum of the products of <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest#getColumnName()"><code>columnName</code></a> times the <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Options#WEIGHT_COLUMN_NAME"><code>WEIGHT\_COLUMN\_NAME</code></a> values divided by the sum of the <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Options#WEIGHT_COLUMN_NAME"><code>WEIGHT\_COLUMN\_NAME</code></a> values. </p>
          <p> Additional columns can be used in the calculation of statistics via <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Options#ADDITIONAL_COLUMN_NAMES"><code>ADDITIONAL\_COLUMN\_NAMES</code></a>. 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 <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#COUNT"><code>COUNT</code></a> and <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#MEAN"><code>MEAN</code></a> of <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest#getColumnName()"><code>columnName</code></a> x and <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Options#ADDITIONAL_COLUMN_NAMES"><code>ADDITIONAL\_COLUMN\_NAMES</code></a> 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). </p>
          <p> The response includes a list of key/value pairs of each statistic requested and its corresponding value.</p>
        </div>

        <div className="dl notes">
          <div className="dt">Parameters:</div>
          <div className="dd"><code>request</code> - <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest" title="class in com.gpudb.protocol"><code>Request</code></a> object containing the parameters for the operation.</div>
          <div className="dt">Returns:</div>
          <div className="dd"><a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsResponse" title="class in com.gpudb.protocol"><code>Response</code></a> object containing the results of the operation.</div>
          <div className="dt">Throws:</div>
          <div className="dd"><code><a href="/content/api/java/com/gpudb/GPUdbException" title="class in com.gpudb">GPUdbException</a></code> - if an error occurs during the operation.</div>
        </div>
      </div>
    </li>

    <li>
      <div className="section detail" id="aggregateStatistics(java.lang.String,java.lang.String,java.lang.String,java.util.Map)">
        <h3>aggregateStatistics</h3>
        <div className="member-signature"><span className="modifiers">public</span> <span className="return-type"><a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsResponse" title="class in com.gpudb.protocol">AggregateStatisticsResponse</a></span> <span className="element-name">aggregateStatistics</span><wbr /><span className="parameters">(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" className="external-link">String</a> tableName, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" className="external-link">String</a> columnName, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" className="external-link">String</a> stats, <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" className="external-link">Map</a>\<<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" className="external-link">String</a>,<wbr /><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" className="external-link">String</a>> options)</span> throws <span className="exceptions"><a href="/content/api/java/com/gpudb/GPUdbException" title="class in com.gpudb">GPUdbException</a></span></div>

        <div className="block">
          Calculates the requested statistics of the given column(s) in a given table.
          <p> The available statistics are: <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#COUNT"><code>COUNT</code></a> (number of total objects), <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#MEAN"><code>MEAN</code></a>, <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#STDV"><code>STDV</code></a> (standard deviation), <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#VARIANCE"><code>VARIANCE</code></a>, <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#SKEW"><code>SKEW</code></a>, <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#KURTOSIS"><code>KURTOSIS</code></a>, <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#SUM"><code>SUM</code></a>, <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#MIN"><code>MIN</code></a>, <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#MAX"><code>MAX</code></a>, <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#WEIGHTED_AVERAGE"><code>WEIGHTED\_AVERAGE</code></a>, <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#CARDINALITY"><code>CARDINALITY</code></a> (unique count), <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#ESTIMATED_CARDINALITY"><code>ESTIMATED\_CARDINALITY</code></a>, <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#PERCENTILE"><code>PERCENTILE</code></a>, and <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#PERCENTILE_RANK"><code>PERCENTILE\_RANK</code></a>. </p>
          <p> Estimated cardinality is calculated by using the hyperloglog approximation technique. </p>
          <p> Percentiles and percentile ranks are approximate and are calculated using the t-digest algorithm. They must include the desired <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#PERCENTILE"><code>PERCENTILE</code></a>/<a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#PERCENTILE_RANK"><code>PERCENTILE\_RANK</code></a>. 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)'). </p>
          <p> A second, comma-separated value can be added to the <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#PERCENTILE"><code>PERCENTILE</code></a> statistic to calculate percentile resolution, e.g., a 50th percentile with 200 resolution would be 'percentile(50,200)'. </p>
          <p> The weighted average statistic requires a weight column to be specified in <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Options#WEIGHT_COLUMN_NAME"><code>WEIGHT\_COLUMN\_NAME</code></a>. The weighted average is then defined as the sum of the products of <code>columnName</code> times the <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Options#WEIGHT_COLUMN_NAME"><code>WEIGHT\_COLUMN\_NAME</code></a> values divided by the sum of the <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Options#WEIGHT_COLUMN_NAME"><code>WEIGHT\_COLUMN\_NAME</code></a> values. </p>
          <p> Additional columns can be used in the calculation of statistics via <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Options#ADDITIONAL_COLUMN_NAMES"><code>ADDITIONAL\_COLUMN\_NAMES</code></a>. 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 <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#COUNT"><code>COUNT</code></a> and <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#MEAN"><code>MEAN</code></a> of <code>columnName</code> x and <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Options#ADDITIONAL_COLUMN_NAMES"><code>ADDITIONAL\_COLUMN\_NAMES</code></a> 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). </p>
          <p> The response includes a list of key/value pairs of each statistic requested and its corresponding value.</p>
        </div>

        <div className="dl notes">
          <div className="dt">Parameters:</div>
          <div className="dd"><code>tableName</code> - Name of the table on which the statistics operation will be performed, in \[schema\_name.]table\_name format, using standard <a href="/content/concepts/tables/#table-name-resolution" target="_top">name resolution rules</a>.</div>
          <div className="dd"><code>columnName</code> - Name of the primary column for which the statistics are to be calculated.</div>

          <div className="dd">
            <code>stats</code> - Comma separated list of the statistics to calculate, e.g. "sum,mean". Supported values:

            <ul>
              <li><a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#COUNT"><code>COUNT</code></a>: Number of objects (independent of the given column(s)). </li>
              <li><a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#MEAN"><code>MEAN</code></a>: Arithmetic mean (average), equivalent to sum/count. </li>
              <li><a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#STDV"><code>STDV</code></a>: Sample standard deviation (denominator is count-1). </li>
              <li><a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#VARIANCE"><code>VARIANCE</code></a>: Unbiased sample variance (denominator is count-1). </li>
              <li><a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#SKEW"><code>SKEW</code></a>: Skewness (third standardized moment). </li>
              <li><a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#KURTOSIS"><code>KURTOSIS</code></a>: Kurtosis (fourth standardized moment). </li>
              <li><a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#SUM"><code>SUM</code></a>: Sum of all values in the column(s). </li>
              <li><a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#MIN"><code>MIN</code></a>: Minimum value of the column(s). </li>
              <li><a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#MAX"><code>MAX</code></a>: Maximum value of the column(s). </li>
              <li><a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#WEIGHTED_AVERAGE"><code>WEIGHTED\_AVERAGE</code></a>: Weighted arithmetic mean (using the option <a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Options#WEIGHT_COLUMN_NAME"><code>WEIGHT\_COLUMN\_NAME</code></a> as the weighting column). </li>
              <li><a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#CARDINALITY"><code>CARDINALITY</code></a>: Number of unique values in the column(s). </li>
              <li><a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#ESTIMATED_CARDINALITY"><code>ESTIMATED\_CARDINALITY</code></a>: Estimate (via hyperloglog technique) of the number of unique values in the column(s). </li>
              <li><a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#PERCENTILE"><code>PERCENTILE</code></a>: Estimate (via t-digest) of the given percentile of the column(s) (percentile(50.0) will be an approximation of the median). Add a second, comma-separated value to calculate percentile resolution, e.g., 'percentile(75,150)'. </li>
              <li><a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Stats#PERCENTILE_RANK"><code>PERCENTILE\_RANK</code></a>: Estimate (via t-digest) of the percentile rank of the given value in the column(s) (if the given value is the median of the column(s), percentile\_rank(\<median>) will return approximately 50.0). </li>
            </ul>
          </div>

          <div className="dd">
            <code>options</code> - Optional parameters.

            <ul>
              <li><a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Options#ADDITIONAL_COLUMN_NAMES"><code>ADDITIONAL\_COLUMN\_NAMES</code></a>: A list of comma separated column names over which statistics can be accumulated along with the primary column. All columns listed and <code>columnName</code> must be of the same type. Must not include the column specified in <code>columnName</code> and no column can be listed twice. </li>
              <li><a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsRequest.Options#WEIGHT_COLUMN_NAME"><code>WEIGHT\_COLUMN\_NAME</code></a>: Name of column used as weighting attribute for the weighted average statistic. </li>
            </ul>

            The default value is an empty <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" className="external-link"><code>Map</code></a>.
          </div>

          <div className="dt">Returns:</div>
          <div className="dd"><a href="/content/api/java/com/gpudb/protocol/AggregateStatisticsResponse" title="class in com.gpudb.protocol"><code>Response</code></a> object containing the results of the operation.</div>
          <div className="dt">Throws:</div>
          <div className="dd"><code><a href="/content/api/java/com/gpudb/GPUdbException" title="class in com.gpudb">GPUdbException</a></code> - if an error occurs during the operation.</div>
        </div>
      </div>
    </li>
  </ul>
</div>
