tencent cloud

Feedback

General Aggregate Functions

Last updated: 2022-05-18 15:01:54

This document introduces the basic syntax and examples of aggregate functions.

An aggregate function calculates a set of values and returns the calculation result. CLS supports the following aggregate functions.

Note:

In CLS analysis statements, strings must be included in single quotes (''), and field names and column names are unsigned or included in double quotes (""). For example, 'status' indicates the string 'status', and status or "status" indicates the log field status.

Function Description Example
arbitrary(KEY) Returns an arbitrary non-null value of KEY. `*
avg(KEY) Returns the average (arithmetic mean) of the KEY column. `*
bitwise_and_agg(KEY) Returns the bitwise AND result of all input values of the KEY column. `*
bitwise_or_agg(KEY) Returns the bitwise OR result of all input values of the KEY column. `*
checksum(KEY) Returns the checksum of the KEY column. The return result is of Base64 encoding type. `*
count(*) Returns the number of input rows. `*
count(1) Returns the number of input rows. This function is equivalent to count(*). `*
count(KEY) Returns the number of non-null input values of the KEY column. `*
count_if(boolean) Returns the number of logs that meet specified conditions. `*
geometric_mean(KEY) Returns the geometric mean of the KEY column. `*
max(KEY) Returns the maximum value of KEY. `*
max_by(x,y) Returns the value of x associated with the maximum value of y over all input values. `*
max_by(x,y,n) Returns n values of x associated with the n largest of all input values of y in descending order of y. `*
min(KEY) Returns the minimum value of KEY. `*
min_by(x,y) Returns the value of x associated with the minimum value of y over all input values. `*
min_by(x,y,n) Returns n values of x associated with the n smallest of all input values of y in descending order of y. `*
sum(KEY) Returns the sum of the KEY column. `*
bool_and(boolean) Returns TRUE if all logs meet the specified condition or FALSE otherwise. `*
bool_or(boolean) Returns TRUE if any log meets the specified condition or FALSE otherwise. `*
every(boolean) Equivalent to bool_and(boolean). `*
`

Parameter description

Parameter Description
KEY Name of the log field.
x The parameter value can be of any data type.
y The parameter value can be of any data type.
n An integer greater than 0.
Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support