Updated on 2024-12-06 GMT+08:00

Aggregate Functions

Table 1 Aggregate functions

No.

MySQL

GaussDB

Difference

1

AVG()

Supported, with differences.

  • In GaussDB, if DISTINCT is specified and the SQL statement contains a GROUP BY clause, the result sequence is not guaranteed.
  • 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.

2

BIT_AND()

Supported.

-

3

BIT_OR()

Supported.

-

4

BIT_XOR()

Supported.

-

5

COUNT()

Supported, with differences.

In GaussDB, if DISTINCT is specified and the SQL statement contains a GROUP BY clause, the result sequence is not guaranteed.

6

GROUP_CONCAT()

Supported, with differences.

  • In GaussDB, if DISTINCT is specified and the SQL statement contains a GROUP BY clause, the result sequence is not guaranteed.
  • 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.

7

MAX()

Supported, with differences.

In GaussDB, if DISTINCT is specified and the SQL statement contains a GROUP BY clause, the result sequence is not guaranteed. When the parameter is not a table field, the return value type of the MAX function is different from that of MySQL 5.7.

8

MIN()

Supported, with differences.

In GaussDB, if DISTINCT is specified and the SQL statement contains a GROUP BY clause, the result sequence is not guaranteed. When the parameter is not a table field, the return value type of the MIN function is different from that of MySQL 5.7.

9

SUM()

Supported, with differences.

  • In GaussDB, if DISTINCT is specified and the SQL statement contains a GROUP BY clause, the result sequence is not guaranteed.
  • 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.