Skip to main content

Overview of expressions

An expression is a general concept that contains several input parameters and returns an output result. The input parameters may come from constants or single-row data, or from multi-row data. An expression can be a combination, and the input of one expression can be the output of another expression.

Based on the source and form, expressions can be classified into the following categories:

  • Column references

  • Constants

  • Operators

  • Functions

Expressions can be used in multiple locations in an SQL statement, such as in the ORDER BY or HAVING clause of a SELECT statement, in the WHERE clause of a SELECT, DELETE, or UPDATE statement, or in a SET statement. You can use values from multiple sources to write an expression, such as literals, column values, NULL, variables, built-in functions and operators, and loaded functions and stored functions (a type of stored object).

Here is an example:

SELECT ABS(a + 1)
FROM t1
WHERE a > 0;

In the preceding example, the parameters are described as follows:

  • a is a column reference.

  • 0 and 1 are constants.

  • > and + are operators, with 0, 1, and a as their input expressions.

  • ABS is a function, with + as its input expression.