Updated on 2025-06-30 GMT+08:00

Aggregate Functions

Table 1 Aggregate functions

MySQL

GaussDB

Difference

AVG()

Supported, with differences.

  • If DISTINCT is specified and the SQL statement contains the GROUP BY clause, GaussDB does not sort the results, while MySQL sorts the results.
  • In GaussDB, if the columns in expr are of the BIT, BOOL, or integer type and the sum of all rows exceeds the range of BIGINT, overflow occurs, reversing integers.

BIT_AND()

Supported.

-

BIT_OR()

Supported.

-

BIT_XOR()

Supported.

-

COUNT()

Supported, with differences.

If DISTINCT is specified and the SQL statement contains the GROUP BY clause, GaussDB does not sort the results, while MySQL sorts the results.

GROUP_CONCAT()

Supported, with differences.

  • If DISTINCT is specified and the SQL statement contains the GROUP BY clause, GaussDB does not sort the results, while MySQL sorts the results.
  • In GaussDB, if the parameters in GROUP_CONCAT contain both the DISTINCT and ORDER BY syntaxes, all expressions following ORDER BY must be in the DISTINCT expression.
  • In GaussDB, GROUP_CONCAT(... ORDER BY Number) does not indicate the sequence of the parameter. The number is only a constant expression, which is equivalent to no sorting.
  • In GaussDB, the group_concat_max_len parameter is used to limit the maximum return length of GROUP_CONCAT. If the return length exceeds the maximum, the length is truncated. Currently, the maximum length that can be returned is 1073741823, which is smaller than that in MySQL.

MAX()

Supported, with differences.

If DISTINCT is specified and the SQL statement contains the GROUP BY clause, GaussDB does not sort the results, while MySQL sorts the results. When the parameter is not a table column, the return value type of the MAX function is different from that of MySQL 5.7.

MIN()

Supported, with differences.

If DISTINCT is specified and the SQL statement contains the GROUP BY clause, GaussDB does not sort the results, while MySQL sorts the results. When the parameter is not a table column, the return value type of the MIN function is different from that of MySQL 5.7.

SUM()

Supported, with differences.

  • If DISTINCT is specified and the SQL statement contains the GROUP BY clause, GaussDB does not sort the results, while MySQL sorts the results.
  • In GaussDB, if the columns in expr are of the BIT, BOOL, or integer type and the sum of all rows exceeds the range of BIGINT, overflow occurs, reversing integers.