Rules for Order of Evaluation - Analytics Database - Teradata Vantage

SQL Functions, Expressions, and Predicates

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-01-12
dita:mapPath
obm1628111499646.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
kby1472250656485
lifecycle
latest
Product Category
Teradata Vantageā„¢
The following rules apply to evaluation order for conditional expressions:
  • If an expression contains more than one of the same operator, the evaluation precedence is left to right.
  • If an expression contains a combination of logical operators, the order of evaluation is as follows:
    NOT

    AND

    OR

  • Parentheses can be used to establish the desired evaluation precedence.
  • The logical expressions in a conditional expression are not always evaluated left to right.

    Avoid using a conditional expression if its accuracy depends on the order in which its logical expressions are evaluated.

    For example, compare the following two expressions:

       F2/(NULLIF(F1,0)) > 500
       F1 <> 0 AND F2/F1 > 500

    The first expression guarantees exclusion of division by zero.

    The second allows the possibility of error, because the order of its evaluation determines the exclusion of zeros.