Order of precedence
The order of precedence defines in which order the elements of an expression are evaluated.
The following list describes the precedence order of expression elements.
For example, the MOD
operator has a higher precedence
as the *
operator. When computing an expression
like ( 33 MOD 2 * 5 )
, the runtime system first
evaluates (33 MOD 2) = 1
and then evaluates (1
* 5) = 5
. The order of evaluation can be changed this by
using parentheses: ( 33 MOD ( 2 * 5 ) ) = 3
.
P  Syntax Element  A  Description  Example 

14 

N  Type casting 

14 

L  Type checking 

13 

L  Singlequalifier interval 

12 

R  Unary plus 

12 

R  Unary minus 

11 

L  Exponentiation 

11 

L  Modulus 

10 

L  Multiplication 

10 

L  Division 

9 

L  Addition 

9 

L  Subtraction 

8 

L  Concatenation 

7 

R  String comparison 

7 

R  String comparison 

6 

L  Less than 

6 

L  Less then or equal to 

6 

L  Greater than 

6 

L  Greater than or equal to 

6 

L  Equals 

6 

L  Not equal to 

5 

L  Test for NULL 

5 

L  Test for NOT NULL 

4 

L  Logical inverse 

3 

L  Logical intersection 

2 

L  Logical union 

1 

R  ASCII Character 

1 

R  Delete trailing blanks 

1 

R  Begin line mode display 

1 

R  Insert blank spaces 

1 

R  SQL State Code 

1 

R  SQL Error Message 

1 

R  Format character string 

1 

L  Assignment 

In this table, the P
column defines the precedence, from highest (14) to lowest
(1). Note that some operators have the same precedence (i.e. are equivalent in evaluation order).
The A
column defines the direction of association (L=Left, R=Right, N=None).