> ## 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-doxygen">
  <div id="ae8be38925c2de5770cde61ce058641c6" />

  <h2 className="memtitle"><span className="permalink"><a href="#ae8be38925c2de5770cde61ce058641c6">◆ </a></span>aggregateStatistics() <span className="overload">\[1/4]</span></h2>

  <div className="memitem">
    <div className="memproto">
      <table className="memname">
        <tr>
          <td className="memname"><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateStatisticsResponse">AggregateStatisticsResponse</a> gpudb::GPUdb::aggregateStatistics </td>
          <td>(</td>
          <td className="paramtype">const <a className="el" href="/content/api/cpp/structgpudb_1_1AggregateStatisticsRequest">AggregateStatisticsRequest</a> &</td>
          <td className="paramname"><span className="paramname"><span className="em">request\_</span></span></td>
          <td>)</td>
          <td> const</td>
        </tr>
      </table>
    </div>

    <div className="memdoc">
      <p>Calculates the requested statistics of the given column(s) in a given table. </p>
      <p>The available statistics are: <a className="el" href="/content/api/cpp/namespacegpudb#a910faa6f48dd193f18aba29b5c960344">count</a> (number of total objects), <a className="el" href="/content/api/cpp/namespacegpudb#a321e05dbc66fb2bd763a96e37c2ef28c">mean</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a80eb30610a806779605b67de7a650a88">stdv</a> (standard deviation), <a className="el" href="/content/api/cpp/namespacegpudb#add21322ff5f88391b8453a054b4b37a2">variance</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a27661ef055a1ceaf3712e11ecf627488">skew</a>, <a className="el" href="/content/api/cpp/namespacegpudb#af4bc4d865eef8b909cd55780ae4af232">kurtosis</a>, <a className="el" href="/content/api/cpp/namespacegpudb#aa117dbda93c32c62770145de97c4c9c2">sum</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a90baeec3c38fc6bd4953070dc6c9d0ea">min</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a912e6ca011bcd0ea98799d9db7152459">max</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a673d92e6228a5a96680db7b385aeceb4">weighted\_average</a>, <a className="el" href="/content/api/cpp/namespacegpudb#aa88f43507d7f396847a0a10a054c8b31">cardinality</a> (unique count), <a className="el" href="/content/api/cpp/namespacegpudb#aecd79bad34930f168402bea13f361615">estimated\_cardinality</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a6b2e607ab0d4568753af82c6cb796057">percentile</a>, and <a className="el" href="/content/api/cpp/namespacegpudb#a543743eb2266f91be3240a5ce00dbfbf">percentile\_rank</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 className="el" href="/content/api/cpp/namespacegpudb#a6b2e607ab0d4568753af82c6cb796057">percentile</a>/<a className="el" href="/content/api/cpp/namespacegpudb#a543743eb2266f91be3240a5ce00dbfbf">percentile\_rank</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 className="el" href="/content/api/cpp/namespacegpudb#a6b2e607ab0d4568753af82c6cb796057">percentile</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 className="el" href="/content/api/cpp/namespacegpudb#a1ab2e07eb9717291d5a706cdb09639ae">weight\_column\_name</a>. The weighted average is then defined as the sum of the products of <a className="el" href="/content/api/cpp/structgpudb_1_1AggregateStatisticsRequest#a89707d310f05b515e33352c74ed15c1e">columnName</a> times the <a className="el" href="/content/api/cpp/namespacegpudb#a1ab2e07eb9717291d5a706cdb09639ae">weight\_column\_name</a> values divided by the sum of the <a className="el" href="/content/api/cpp/namespacegpudb#a1ab2e07eb9717291d5a706cdb09639ae">weight\_column\_name</a> values.</p>
      <p>Additional columns can be used in the calculation of statistics via <a className="el" href="/content/api/cpp/namespacegpudb#ac247aec8a5036be28db98f2a2b7f01f2">additional\_column\_names</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 className="el" href="/content/api/cpp/namespacegpudb#a910faa6f48dd193f18aba29b5c960344">count</a> and <a className="el" href="/content/api/cpp/namespacegpudb#a321e05dbc66fb2bd763a96e37c2ef28c">mean</a> of <a className="el" href="/content/api/cpp/structgpudb_1_1AggregateStatisticsRequest#a89707d310f05b515e33352c74ed15c1e">columnName</a> x and <a className="el" href="/content/api/cpp/namespacegpudb#ac247aec8a5036be28db98f2a2b7f01f2">additional\_column\_names</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 className="dl params">
        <div className="dt">Parameters</div>

        <div className="dd">
          <table className="params">
            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">request\_</td>
              <td><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateStatisticsRequest">Request</a> object containing the parameters for the operation.</td>
            </tr>
          </table>
        </div>
      </div>

      <div className="dl section return">
        <div className="dt">Returns</div>
        <div className="dd"><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateStatisticsResponse">Response</a> object containing the result of the operation. </div>
      </div>
    </div>
  </div>

  <div id="a2ec160656cda21fb8968cd0dd74cfc68" />

  <h2 className="memtitle"><span className="permalink"><a href="#a2ec160656cda21fb8968cd0dd74cfc68">◆ </a></span>aggregateStatistics() <span className="overload">\[2/4]</span></h2>

  <div className="memitem">
    <div className="memproto">
      <table className="memname">
        <tr>
          <td className="memname"><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateStatisticsResponse">AggregateStatisticsResponse</a> & gpudb::GPUdb::aggregateStatistics </td>
          <td>(</td>
          <td className="paramtype">const <a className="el" href="/content/api/cpp/structgpudb_1_1AggregateStatisticsRequest">AggregateStatisticsRequest</a> &</td>
          <td className="paramname"><span className="paramname"><span className="em">request\_</span></span>, </td>
        </tr>

        <tr>
          <td className="paramkey" />

          <td />

          <td className="paramtype"><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateStatisticsResponse">AggregateStatisticsResponse</a> &</td>
          <td className="paramname"><span className="paramname"><span className="em">response\_</span></span> ) const</td>
        </tr>
      </table>
    </div>

    <div className="memdoc">
      <p>Calculates the requested statistics of the given column(s) in a given table. </p>
      <p>The available statistics are: <a className="el" href="/content/api/cpp/namespacegpudb#a910faa6f48dd193f18aba29b5c960344">count</a> (number of total objects), <a className="el" href="/content/api/cpp/namespacegpudb#a321e05dbc66fb2bd763a96e37c2ef28c">mean</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a80eb30610a806779605b67de7a650a88">stdv</a> (standard deviation), <a className="el" href="/content/api/cpp/namespacegpudb#add21322ff5f88391b8453a054b4b37a2">variance</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a27661ef055a1ceaf3712e11ecf627488">skew</a>, <a className="el" href="/content/api/cpp/namespacegpudb#af4bc4d865eef8b909cd55780ae4af232">kurtosis</a>, <a className="el" href="/content/api/cpp/namespacegpudb#aa117dbda93c32c62770145de97c4c9c2">sum</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a90baeec3c38fc6bd4953070dc6c9d0ea">min</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a912e6ca011bcd0ea98799d9db7152459">max</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a673d92e6228a5a96680db7b385aeceb4">weighted\_average</a>, <a className="el" href="/content/api/cpp/namespacegpudb#aa88f43507d7f396847a0a10a054c8b31">cardinality</a> (unique count), <a className="el" href="/content/api/cpp/namespacegpudb#aecd79bad34930f168402bea13f361615">estimated\_cardinality</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a6b2e607ab0d4568753af82c6cb796057">percentile</a>, and <a className="el" href="/content/api/cpp/namespacegpudb#a543743eb2266f91be3240a5ce00dbfbf">percentile\_rank</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 className="el" href="/content/api/cpp/namespacegpudb#a6b2e607ab0d4568753af82c6cb796057">percentile</a>/<a className="el" href="/content/api/cpp/namespacegpudb#a543743eb2266f91be3240a5ce00dbfbf">percentile\_rank</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 className="el" href="/content/api/cpp/namespacegpudb#a6b2e607ab0d4568753af82c6cb796057">percentile</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 className="el" href="/content/api/cpp/namespacegpudb#a1ab2e07eb9717291d5a706cdb09639ae">weight\_column\_name</a>. The weighted average is then defined as the sum of the products of <a className="el" href="/content/api/cpp/structgpudb_1_1AggregateStatisticsRequest#a89707d310f05b515e33352c74ed15c1e">columnName</a> times the <a className="el" href="/content/api/cpp/namespacegpudb#a1ab2e07eb9717291d5a706cdb09639ae">weight\_column\_name</a> values divided by the sum of the <a className="el" href="/content/api/cpp/namespacegpudb#a1ab2e07eb9717291d5a706cdb09639ae">weight\_column\_name</a> values.</p>
      <p>Additional columns can be used in the calculation of statistics via <a className="el" href="/content/api/cpp/namespacegpudb#ac247aec8a5036be28db98f2a2b7f01f2">additional\_column\_names</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 className="el" href="/content/api/cpp/namespacegpudb#a910faa6f48dd193f18aba29b5c960344">count</a> and <a className="el" href="/content/api/cpp/namespacegpudb#a321e05dbc66fb2bd763a96e37c2ef28c">mean</a> of <a className="el" href="/content/api/cpp/structgpudb_1_1AggregateStatisticsRequest#a89707d310f05b515e33352c74ed15c1e">columnName</a> x and <a className="el" href="/content/api/cpp/namespacegpudb#ac247aec8a5036be28db98f2a2b7f01f2">additional\_column\_names</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 className="dl params">
        <div className="dt">Parameters</div>

        <div className="dd">
          <table className="params">
            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">request\_</td>
              <td><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateStatisticsRequest">Request</a> object containing the parameters for the operation. </td>
            </tr>

            <tr>
              <td className="paramdir">\[out]</td>
              <td className="paramname">response\_</td>
              <td><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateStatisticsResponse">Response</a> object containing the results of the operation.</td>
            </tr>
          </table>
        </div>
      </div>

      <div className="dl section return">
        <div className="dt">Returns</div>
        <div className="dd"><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateStatisticsResponse">Response</a> object containing the result of the operation (initially passed in by reference). </div>
      </div>
    </div>
  </div>

  <div id="a14e2268cde99791da1ffb54f1f8326cb" />

  <h2 className="memtitle"><span className="permalink"><a href="#a14e2268cde99791da1ffb54f1f8326cb">◆ </a></span>aggregateStatistics() <span className="overload">\[3/4]</span></h2>

  <div className="memitem">
    <div className="memproto">
      <table className="memname">
        <tr>
          <td className="memname"><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateStatisticsResponse">AggregateStatisticsResponse</a> gpudb::GPUdb::aggregateStatistics </td>
          <td>(</td>
          <td className="paramtype">const std::string &</td>
          <td className="paramname"><span className="paramname"><span className="em">tableName</span></span>, </td>
        </tr>

        <tr>
          <td className="paramkey" />

          <td />

          <td className="paramtype">const std::string &</td>
          <td className="paramname"><span className="paramname"><span className="em">columnName</span></span>, </td>
        </tr>

        <tr>
          <td className="paramkey" />

          <td />

          <td className="paramtype">const std::string &</td>
          <td className="paramname"><span className="paramname"><span className="em">stats</span></span>, </td>
        </tr>

        <tr>
          <td className="paramkey" />

          <td />

          <td className="paramtype">const std::map\< std::string, std::string > &</td>
          <td className="paramname"><span className="paramname"><span className="em">options</span></span> ) const</td>
        </tr>
      </table>
    </div>

    <div className="memdoc">
      <p>Calculates the requested statistics of the given column(s) in a given table. </p>
      <p>The available statistics are: <a className="el" href="/content/api/cpp/namespacegpudb#a910faa6f48dd193f18aba29b5c960344">count</a> (number of total objects), <a className="el" href="/content/api/cpp/namespacegpudb#a321e05dbc66fb2bd763a96e37c2ef28c">mean</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a80eb30610a806779605b67de7a650a88">stdv</a> (standard deviation), <a className="el" href="/content/api/cpp/namespacegpudb#add21322ff5f88391b8453a054b4b37a2">variance</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a27661ef055a1ceaf3712e11ecf627488">skew</a>, <a className="el" href="/content/api/cpp/namespacegpudb#af4bc4d865eef8b909cd55780ae4af232">kurtosis</a>, <a className="el" href="/content/api/cpp/namespacegpudb#aa117dbda93c32c62770145de97c4c9c2">sum</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a90baeec3c38fc6bd4953070dc6c9d0ea">min</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a912e6ca011bcd0ea98799d9db7152459">max</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a673d92e6228a5a96680db7b385aeceb4">weighted\_average</a>, <a className="el" href="/content/api/cpp/namespacegpudb#aa88f43507d7f396847a0a10a054c8b31">cardinality</a> (unique count), <a className="el" href="/content/api/cpp/namespacegpudb#aecd79bad34930f168402bea13f361615">estimated\_cardinality</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a6b2e607ab0d4568753af82c6cb796057">percentile</a>, and <a className="el" href="/content/api/cpp/namespacegpudb#a543743eb2266f91be3240a5ce00dbfbf">percentile\_rank</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 className="el" href="/content/api/cpp/namespacegpudb#a6b2e607ab0d4568753af82c6cb796057">percentile</a>/<a className="el" href="/content/api/cpp/namespacegpudb#a543743eb2266f91be3240a5ce00dbfbf">percentile\_rank</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 className="el" href="/content/api/cpp/namespacegpudb#a6b2e607ab0d4568753af82c6cb796057">percentile</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 className="el" href="/content/api/cpp/namespacegpudb#a1ab2e07eb9717291d5a706cdb09639ae">weight\_column\_name</a>. The weighted average is then defined as the sum of the products of <span className="em arg">columnName</span> times the <a className="el" href="/content/api/cpp/namespacegpudb#a1ab2e07eb9717291d5a706cdb09639ae">weight\_column\_name</a> values divided by the sum of the <a className="el" href="/content/api/cpp/namespacegpudb#a1ab2e07eb9717291d5a706cdb09639ae">weight\_column\_name</a> values.</p>
      <p>Additional columns can be used in the calculation of statistics via <a className="el" href="/content/api/cpp/namespacegpudb#ac247aec8a5036be28db98f2a2b7f01f2">additional\_column\_names</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 className="el" href="/content/api/cpp/namespacegpudb#a910faa6f48dd193f18aba29b5c960344">count</a> and <a className="el" href="/content/api/cpp/namespacegpudb#a321e05dbc66fb2bd763a96e37c2ef28c">mean</a> of <span className="em arg">columnName</span> x and <a className="el" href="/content/api/cpp/namespacegpudb#ac247aec8a5036be28db98f2a2b7f01f2">additional\_column\_names</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 className="dl params">
        <div className="dt">Parameters</div>

        <div className="dd">
          <table className="params">
            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">tableName</td>
              <td>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>. </td>
            </tr>

            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">columnName</td>
              <td>Name of the primary column for which the statistics are to be calculated. </td>
            </tr>

            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">stats</td>

              <td>
                Comma separated list of the statistics to calculate, e.g. "sum,mean". Supported values:

                <ul>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#a910faa6f48dd193f18aba29b5c960344">aggregate\_statistics\_count</a>: Number of objects (independent of the given column(s)). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#a321e05dbc66fb2bd763a96e37c2ef28c">aggregate\_statistics\_mean</a>: Arithmetic mean (average), equivalent to sum/count. </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#a80eb30610a806779605b67de7a650a88">aggregate\_statistics\_stdv</a>: Sample standard deviation (denominator is count-1). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#add21322ff5f88391b8453a054b4b37a2">aggregate\_statistics\_variance</a>: Unbiased sample variance (denominator is count-1). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#a27661ef055a1ceaf3712e11ecf627488">aggregate\_statistics\_skew</a>: Skewness (third standardized moment). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#af4bc4d865eef8b909cd55780ae4af232">aggregate\_statistics\_kurtosis</a>: Kurtosis (fourth standardized moment). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#aa117dbda93c32c62770145de97c4c9c2">aggregate\_statistics\_sum</a>: Sum of all values in the column(s). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#a90baeec3c38fc6bd4953070dc6c9d0ea">aggregate\_statistics\_min</a>: Minimum value of the column(s). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#a912e6ca011bcd0ea98799d9db7152459">aggregate\_statistics\_max</a>: Maximum value of the column(s). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#a673d92e6228a5a96680db7b385aeceb4">aggregate\_statistics\_weighted\_average</a>: Weighted arithmetic mean (using the option <a className="el" href="/content/api/cpp/namespacegpudb#a1ab2e07eb9717291d5a706cdb09639ae">weight\_column\_name</a> as the weighting column). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#aa88f43507d7f396847a0a10a054c8b31">aggregate\_statistics\_cardinality</a>: Number of unique values in the column(s). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#aecd79bad34930f168402bea13f361615">aggregate\_statistics\_estimated\_cardinality</a>: Estimate (via hyperloglog technique) of the number of unique values in the column(s). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#a6b2e607ab0d4568753af82c6cb796057">aggregate\_statistics\_percentile</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 className="el" href="/content/api/cpp/namespacegpudb#a543743eb2266f91be3240a5ce00dbfbf">aggregate\_statistics\_percentile\_rank</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>
              </td>
            </tr>

            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">options</td>

              <td>
                Optional parameters.

                <ul>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#ac247aec8a5036be28db98f2a2b7f01f2">aggregate\_statistics\_additional\_column\_names</a>: A list of comma separated column names over which statistics can be accumulated along with the primary column. All columns listed and <span className="em arg">columnName</span> must be of the same type. Must not include the column specified in <span className="em arg">columnName</span> and no column can be listed twice. </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#a1ab2e07eb9717291d5a706cdb09639ae">aggregate\_statistics\_weight\_column\_name</a>: Name of column used as weighting attribute for the weighted average statistic. </li>
                </ul>

                The default value is an empty map.
              </td>
            </tr>
          </table>
        </div>
      </div>

      <div className="dl section return">
        <div className="dt">Returns</div>
        <div className="dd"><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateStatisticsResponse">Response</a> object containing the result of the operation. </div>
      </div>
    </div>
  </div>

  <div id="ad2e88c5ed0f712c53671d74f8690f8c6" />

  <h2 className="memtitle"><span className="permalink"><a href="#ad2e88c5ed0f712c53671d74f8690f8c6">◆ </a></span>aggregateStatistics() <span className="overload">\[4/4]</span></h2>

  <div className="memitem">
    <div className="memproto">
      <table className="memname">
        <tr>
          <td className="memname"><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateStatisticsResponse">AggregateStatisticsResponse</a> & gpudb::GPUdb::aggregateStatistics </td>
          <td>(</td>
          <td className="paramtype">const std::string &</td>
          <td className="paramname"><span className="paramname"><span className="em">tableName</span></span>, </td>
        </tr>

        <tr>
          <td className="paramkey" />

          <td />

          <td className="paramtype">const std::string &</td>
          <td className="paramname"><span className="paramname"><span className="em">columnName</span></span>, </td>
        </tr>

        <tr>
          <td className="paramkey" />

          <td />

          <td className="paramtype">const std::string &</td>
          <td className="paramname"><span className="paramname"><span className="em">stats</span></span>, </td>
        </tr>

        <tr>
          <td className="paramkey" />

          <td />

          <td className="paramtype">const std::map\< std::string, std::string > &</td>
          <td className="paramname"><span className="paramname"><span className="em">options</span></span>, </td>
        </tr>

        <tr>
          <td className="paramkey" />

          <td />

          <td className="paramtype"><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateStatisticsResponse">AggregateStatisticsResponse</a> &</td>
          <td className="paramname"><span className="paramname"><span className="em">response\_</span></span> ) const</td>
        </tr>
      </table>
    </div>

    <div className="memdoc">
      <p>Calculates the requested statistics of the given column(s) in a given table. </p>
      <p>The available statistics are: <a className="el" href="/content/api/cpp/namespacegpudb#a910faa6f48dd193f18aba29b5c960344">count</a> (number of total objects), <a className="el" href="/content/api/cpp/namespacegpudb#a321e05dbc66fb2bd763a96e37c2ef28c">mean</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a80eb30610a806779605b67de7a650a88">stdv</a> (standard deviation), <a className="el" href="/content/api/cpp/namespacegpudb#add21322ff5f88391b8453a054b4b37a2">variance</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a27661ef055a1ceaf3712e11ecf627488">skew</a>, <a className="el" href="/content/api/cpp/namespacegpudb#af4bc4d865eef8b909cd55780ae4af232">kurtosis</a>, <a className="el" href="/content/api/cpp/namespacegpudb#aa117dbda93c32c62770145de97c4c9c2">sum</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a90baeec3c38fc6bd4953070dc6c9d0ea">min</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a912e6ca011bcd0ea98799d9db7152459">max</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a673d92e6228a5a96680db7b385aeceb4">weighted\_average</a>, <a className="el" href="/content/api/cpp/namespacegpudb#aa88f43507d7f396847a0a10a054c8b31">cardinality</a> (unique count), <a className="el" href="/content/api/cpp/namespacegpudb#aecd79bad34930f168402bea13f361615">estimated\_cardinality</a>, <a className="el" href="/content/api/cpp/namespacegpudb#a6b2e607ab0d4568753af82c6cb796057">percentile</a>, and <a className="el" href="/content/api/cpp/namespacegpudb#a543743eb2266f91be3240a5ce00dbfbf">percentile\_rank</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 className="el" href="/content/api/cpp/namespacegpudb#a6b2e607ab0d4568753af82c6cb796057">percentile</a>/<a className="el" href="/content/api/cpp/namespacegpudb#a543743eb2266f91be3240a5ce00dbfbf">percentile\_rank</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 className="el" href="/content/api/cpp/namespacegpudb#a6b2e607ab0d4568753af82c6cb796057">percentile</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 className="el" href="/content/api/cpp/namespacegpudb#a1ab2e07eb9717291d5a706cdb09639ae">weight\_column\_name</a>. The weighted average is then defined as the sum of the products of <span className="em arg">columnName</span> times the <a className="el" href="/content/api/cpp/namespacegpudb#a1ab2e07eb9717291d5a706cdb09639ae">weight\_column\_name</a> values divided by the sum of the <a className="el" href="/content/api/cpp/namespacegpudb#a1ab2e07eb9717291d5a706cdb09639ae">weight\_column\_name</a> values.</p>
      <p>Additional columns can be used in the calculation of statistics via <a className="el" href="/content/api/cpp/namespacegpudb#ac247aec8a5036be28db98f2a2b7f01f2">additional\_column\_names</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 className="el" href="/content/api/cpp/namespacegpudb#a910faa6f48dd193f18aba29b5c960344">count</a> and <a className="el" href="/content/api/cpp/namespacegpudb#a321e05dbc66fb2bd763a96e37c2ef28c">mean</a> of <span className="em arg">columnName</span> x and <a className="el" href="/content/api/cpp/namespacegpudb#ac247aec8a5036be28db98f2a2b7f01f2">additional\_column\_names</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 className="dl params">
        <div className="dt">Parameters</div>

        <div className="dd">
          <table className="params">
            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">tableName</td>
              <td>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>. </td>
            </tr>

            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">columnName</td>
              <td>Name of the primary column for which the statistics are to be calculated. </td>
            </tr>

            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">stats</td>

              <td>
                Comma separated list of the statistics to calculate, e.g. "sum,mean". Supported values:

                <ul>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#a910faa6f48dd193f18aba29b5c960344">aggregate\_statistics\_count</a>: Number of objects (independent of the given column(s)). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#a321e05dbc66fb2bd763a96e37c2ef28c">aggregate\_statistics\_mean</a>: Arithmetic mean (average), equivalent to sum/count. </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#a80eb30610a806779605b67de7a650a88">aggregate\_statistics\_stdv</a>: Sample standard deviation (denominator is count-1). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#add21322ff5f88391b8453a054b4b37a2">aggregate\_statistics\_variance</a>: Unbiased sample variance (denominator is count-1). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#a27661ef055a1ceaf3712e11ecf627488">aggregate\_statistics\_skew</a>: Skewness (third standardized moment). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#af4bc4d865eef8b909cd55780ae4af232">aggregate\_statistics\_kurtosis</a>: Kurtosis (fourth standardized moment). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#aa117dbda93c32c62770145de97c4c9c2">aggregate\_statistics\_sum</a>: Sum of all values in the column(s). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#a90baeec3c38fc6bd4953070dc6c9d0ea">aggregate\_statistics\_min</a>: Minimum value of the column(s). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#a912e6ca011bcd0ea98799d9db7152459">aggregate\_statistics\_max</a>: Maximum value of the column(s). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#a673d92e6228a5a96680db7b385aeceb4">aggregate\_statistics\_weighted\_average</a>: Weighted arithmetic mean (using the option <a className="el" href="/content/api/cpp/namespacegpudb#a1ab2e07eb9717291d5a706cdb09639ae">weight\_column\_name</a> as the weighting column). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#aa88f43507d7f396847a0a10a054c8b31">aggregate\_statistics\_cardinality</a>: Number of unique values in the column(s). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#aecd79bad34930f168402bea13f361615">aggregate\_statistics\_estimated\_cardinality</a>: Estimate (via hyperloglog technique) of the number of unique values in the column(s). </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#a6b2e607ab0d4568753af82c6cb796057">aggregate\_statistics\_percentile</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 className="el" href="/content/api/cpp/namespacegpudb#a543743eb2266f91be3240a5ce00dbfbf">aggregate\_statistics\_percentile\_rank</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>
              </td>
            </tr>

            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">options</td>

              <td>
                Optional parameters.

                <ul>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#ac247aec8a5036be28db98f2a2b7f01f2">aggregate\_statistics\_additional\_column\_names</a>: A list of comma separated column names over which statistics can be accumulated along with the primary column. All columns listed and <span className="em arg">columnName</span> must be of the same type. Must not include the column specified in <span className="em arg">columnName</span> and no column can be listed twice. </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#a1ab2e07eb9717291d5a706cdb09639ae">aggregate\_statistics\_weight\_column\_name</a>: Name of column used as weighting attribute for the weighted average statistic. </li>
                </ul>

                The default value is an empty map.
              </td>
            </tr>

            <tr>
              <td className="paramdir">\[out]</td>
              <td className="paramname">response\_</td>
              <td><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateStatisticsResponse">Response</a> object containing the results of the operation.</td>
            </tr>
          </table>
        </div>
      </div>

      <div className="dl section return">
        <div className="dt">Returns</div>
        <div className="dd"><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateStatisticsResponse">Response</a> object containing the result of the operation (initially passed in by reference). </div>
      </div>
    </div>
  </div>
</div>
