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

Analysis Statements - Aggregate Functions

The syntax of a complete analysis statement is as follows:

SELECT [DISTINCT] (* | expression) [AS alias] [, ...]
[GROUP BY expression [, ...] [HAVING predicates]]
[ORDER BY expression [ASC | DESC] [, ...]]
[LIMIT size OFFSET offset]

This section describes some aggregate functions.

Table 1 Aggregate functions

Function

Purpose

Description

Example Value

avg

Average value

avg(number T) -> T

SELECT avg(age) LIMIT 1

sum

Sum

sum(number T) -> T

SELECT sum(age) LIMIT 1

min

Specifies the minimum value.

min(number T) -> T

SELECT min(age) LIMIT 1

max

Maximum value

max(number T) -> T

SELECT max(age) LIMIT 1

count

Occurrences

count(field) -> integer ,

count(*) -> integer ,

count(1) -> integer

SELECT count(age) LIMIT 1 ,

SELECT count(*) LIMIT 1 ,

SELECT count(1) LIMIT 1