All Products
Search
Document Center

Lindorm:Aggregate functions

Last Updated:Apr 25, 2024

This topic describes the aggregate functions supported by Lindorm.

Applicable engines and versions

The functions described in this topic are applicable to the following Lindorm engines of specific versions:

  • LindormTable of all versions

  • LindormTSDB V3.4.7 and later versions

Functions

The following table describes the aggregate functions supported by Lindorm.

Function

Description

AVG

Returns the average of all values in the specified column.

COUNT

Returns the number of non-empty values in the specified column.

MAX

Returns the maximum value of the specified column.

MIN

Returns the minimum value of the specified column.

SUM

Returns the sum of values in the specified column.

AVG

You can call this function to obtain the average of all values in the specified column.

Syntax

AVG(column_name)

Parameters

Parameter

Description

column_name

The name of the column. Only columns of the numeric data type are supported.

Examples

Calculate the average of the temperature values collected from all devices.

SELECT AVG(temperature) AS temperature FROM sensor;

COUNT

You can call this function to obtain the number of non-empty values in the specified column.

Syntax

COUNT(* | column_name)

Parameters

Parameter

Description

column_name

The name of the column.

Examples

  • Count the number of temperature values collected from all devices.

SELECT COUNT(temperature) AS temperature FROM sensor;
  • Count the number of rows in which the value of the device_id column is F07A1260 in the sensor table.

SELECT COUNT(*) FROM sensor WHERE region = 'F07A1260';
  • Count the number of rows in the sensor table.

SELECT COUNT(*) FROM sensor;

MAX

You can call this function to obtain the maximum value of the specified column.

Syntax

MAX(column_name)

Parameters

Parameter

Description

column_name

The name of the column.

Examples

Query the maximum value of the temperature values collected from all devices.

SELECT MAX(temperature) FROM sensor;

MIN

You can call this function to obtain the minimum value of the specified column.

Syntax

MIN(column_name)

Parameters

Parameter

Description

column_name

The name of the column.

Examples

Query the minimum value of the temperature values collected from all devices.

SELECT MIN(temperature) FROM sensor;

SUM

You can call this function to obtain the sum of values in the specified column.

Syntax

SUM(column_name)

Parameters

Parameter

Description

column_name

The name of the column. Only columns of the numeric data type are supported.

Examples

Query the sum of the temperature values collected from all devices.

SELECT SUM(temperature) FROM sensor;