Using Parentheses to Customize Precedence - Analytics Database - Teradata Vantage

SQL Data Manipulation Language

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-10-04
dita:mapPath
pon1628111750298.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
esx1472246586715
lifecycle
latest
Product Category
Teradata Vantageā„¢

To override precedence, use parentheses. Operations in parentheses are performed first.

For example, consider the following form:

   ( ( SELECT statement_1 
       UNION 
       SELECT statement_2 )
   EXCEPT
     ( SELECT statement_3 
       UNION 
       SELECT statement_4 )
   )
   EXCEPT 
   SELECT statement_5 
   INTERSECT 
   SELECT statement_6;

The following list explains the precedence of operators for this example.

  1. UNION SELECT statement _1 and SELECT statement _2.
  2. UNION SELECT statement _3 and SELECT statement _4.
  3. Subtract the result of the second UNION from the result of the first UNION.
  4. INTERSECT SELECT statement _5 and SELECT statement _6.
  5. Subtract the INTERSECT result from the remainder of the UNION operations.