Precedence of operations
Expressions within parentheses are evaluated first. When the order of evaluation is not specified by parentheses, prefix operators are applied before multiplication and division, and multiplication, division, and concatenation are applied before addition and subtraction. Operators at the same precedence level are applied from left to right.
Example 1: In this example, the first operation is the addition
in (SALARY + BONUS) because it is within parenthesis.
The second operation is multiplication because it is a higher precedence
level than the second addition operator and it is to the left of the
division operator. The third operation is division because it is at
a higher precedence level than the second addition operator. Finally,
the remaining addition is performed.
1.10 * (SALARY + BONUS) + SALARY / :VAR3
(2) (1) (4) (3)
Example 2: In this example, the first operation (CONCAT)
combines the character strings in the variables YYYYMM and DD into
a string representing a date. The second operation (-) then subtracts
that date from the date being processed in DATECOL. The result is
a date duration that indicates the time elapsed between the two dates.
DATECOL - :YYYYMM CONCAT :DD
(2) (1)