An SQL **Value Expression** is a sequence of **Literals**, **Operators**, and **Function Calls** to produce a single result.

value-expression ::=

value-term [ { term-operator value-term } ]

term-operator ::=

+ | -

value-term ::=

value-factor [ { factor-operator value-factor } ]

factor-operator ::=

* | / | '||'

factor ::=

[ - ] primary

primary ::=

nonparenthesized-value-primary

| ( value-expression )

nonparenthesized-value-primary ::=

literal

| primary-literal-string

| primary-literal-datetime

| primary-literal-interval

| primary-case

| primary-cast

| primary-coalesce

| primary-nullif

| primary-function-length

| primary-function-math

| primary-function-position

| primary-function-substring

| primary-function-string

| primary-function-trim

| primary-conversion-function

| primary-set-function

| primary-column-reference

| primary-dynamic-parameter

| primary-host-parameter

A binary operator performs an operation on two values to return a single result. These binary operators are supported:

Operator | Description | Precedence |
---|---|---|

+ | Addition | 1 |

- | Subtraction | 1 |

* | Multiply | 2 |

/ | Divide | 2 |

|| | String concatenation | 2 |

When multiple operators are present in an expression, higher precedence operators are evaluated before lower precedence operators. When two operators have equal precedence, the left operator is evaluated before the right operator. For example:

Expression | Evaluation Order |
---|---|

A + B * C | B is multiplied by C, then the result is added to A |

A + B + C | B is added to A, then C is added to the result of A + B |

A * B + C | A is multiplied by B, then C is added to the result of A * B |

Parentheses alter the order of evaluation of operators. An expression inside parentheses is always evaluated first, regardless of operator precedence. For example:

Expression | Evaluation Order |
---|---|

(A + B) * C | B is added to A, then the result of A + B is multiplied by C |

To learn more about SQL scalar value expressions.

Fernhill SCADA Structured Query Language (SQL)

To learn more about the SQL features in Fernhill SCADA.

For definitions of the terms used in **Fernhill SCADA**.