Skip to content

Expression Query

An expression query is a method of performing data calculations and analyses by adding and combining multiple query statements. It allows the use of mathematical operators and functions in queries for more complex processing and transformation of data.

Concepts

Term Description
Expression Composed of one or more query statements, combined and calculated using mathematical operators (such as +, -, *, /) and functions (such as SUM, AVG, MAX).
Group Labels Used to identify and differentiate groups of different query statements. In an expression query, all query statements must have consistent group labels to ensure accurate calculations.
Unit Handling If the query statements include units (such as KB, MB, seconds, etc.), the calculation results will retain the same units. For example, if Query A's unit is KB, then the unit of A + 100 is also KB.

Query Examples

Example 1: Calculating the sum of two queries

Assume you have two query statements:

  • Query A: Returns the total sum of data
  • Query B: Returns the average value of data

You can use an expression query to calculate their sum: A+B


Example 2: Converting units of query results

Assume Query A returns data in units of KB, and you want to convert it to MB: A/1024


Example 3: Performing complex calculations with functions

Assume you need to calculate the difference between the maximum value of Query A and the minimum value of Query B: MAX(A)-MIN(B)

Note
  • Consistent Group Labels: In an expression query, all query statements must have consistent group labels; otherwise, it may lead to calculation errors;
  • Consistent Units: In expression calculations, if the query statements include units, the calculation results will retain the same units;
  • Performance Optimization: Complex expression queries might affect query performance; preprocessing the data may be necessary when required.

Feedback

Is this page helpful? ×