Updated on 2025-09-05 GMT+08:00

Aggregate Functions

The following table lists the aggregate functions supported by SecMaster SQL syntax.

Table 1 Aggregate functions supported by SecMaster SQL syntax

Function

Function Description

COUNT([ ALL ] expression | DISTINCT expression1 [, expression2]*)

By default or with the keyword ALL, returns the number of input rows where the expression is not NULL. Using DISTINCT calculates the count after removing duplicates.

COUNT(*) | COUNT(1)

Returns the number of input rows.

AVG([ ALL | DISTINCT ] expression)

By default or with the keyword ALL, returns the average value (arithmetic mean) of the expression across all input rows. Using DISTINCT calculates the count after removing duplicates.

SUM([ ALL | DISTINCT ] expression)

By default or with the keyword ALL, returns the sum of the expression across all input rows. Using DISTINCT calculates the count after removing duplicates.

MAX([ ALL | DISTINCT ] expression)

By default or with the keyword ALL, returns the maximum value of the expression across all input rows. Using DISTINCT calculates the count after removing duplicates.

MIN([ ALL | DISTINCT ] expression )

By default or with the keyword ALL, returns the maximum value of the expression across all input rows. Using DISTINCT calculates the count after removing duplicates.

ROW_NUMBER()

Assigns a unique sequence number to each row within the window partition, starting from 1. (for example, 1, 2, 3, 4, and 5)

FIRST_VALUE(expression)

Returns the first value in a set of ordered values.

LAST_VALUE(expression)

Returns the last value in a set of ordered values.

LISTAGG(expression [, separator])

Concatenates the values of string expressions and places a separator value between them. The separator is not added at the end of string. The default value of separator is a comma (,).