Expressions

Expressions

Expressions are the combination of symbols and operators used to obtain a single data value. Simple expressions can be a single constant, column, or scalar function. Operators can be used to join two or more simple expressions into a complex expression.

Syntax


{ constant
  | scalar_function
  | [ alias. ] column
  | ( expression )
  | ( scalar_subquery )
  | { unary_operator } expression
  | expression { binary_operator } expression
}

Arguments

constant

Is a symbol that represents a single, specific data value. Character and datetime values are enclosed in single or double quotation marks, while binary strings and numeric constants are not. 

scalar_function

Is a unit of SQL syntax that provides a specific service and returns a single value. scalar_function can be built-in scalar functions, such as the SUM, or CAST functions, or .NET scalar functions like System.Timespan.Now.

[alias.]

Is the alias name assigned to a table by the AS keyword in the FROM clause.

column

Is the name of a column.

(expression)

Is any valid SQL expression as defined in this topic. The parentheses are grouping operators that ensure that all the operators in the expression within the parentheses are evaluated before the resulting expression is combined with another.

(scalar_subquery)

Is a sub-query that returns one value. For example:

SELECT MAX(c1) FROM tab1

{unary_operator}

Is an operator that has only one numeric operand:
indicates a positive number
- indicates a negative number.
~ indicates the one's complement operator.

Unary operators can be applied only to expressions that evaluate to any of the numeric data types.

{binary_operator}

Is an operator that defines the way two expressions are combined to yield a single result. binary_operator can be an arithmetic operator, the assignment operator (=), a bitwise operator, a comparison operator, a logical operator, the string concatenation operator ( ), or a unary operator.