SQL Operators | SQL Fundamentals | Teradata Vantage - Operators - Advanced SQL Engine - Teradata Database

SQL Fundamentals

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-24
dita:mapPath
zwv1557098532464.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1141
lifecycle
previous
Product Category
Teradata Vantageâ„¢

SQL operators express logical and arithmetic operations. Operators of the same precedence are evaluated from left to right.

Parentheses can be used to control the order of precedence. When parentheses are present, operations are performed from the innermost set of parentheses outward.

The following definitions apply to SQL operators.

Term Definition
numeric Any literal, data reference, or expression having a numeric value.
string Any character string or string expression.
logical A Boolean expression (resolves to TRUE, FALSE, or unknown).
value Any numeric, character, or byte data item.
set A collection of values returned by a subquery, or a list of values separated by commas and enclosed by parentheses.

SQL Operations and Precedence

SQL operations, and the order in which they are performed when no parentheses are present, appear in the following table. Operators of the same precedence are evaluated from left to right.

Precedence Result Type Operation
highest numeric + numeric   (unary plus)

- numeric    (unary minus)

intermediate numeric numeric ** numeric     (exponentiation)
numeric numeric * numeric     (multiplication)

numeric / numeric     (division)

numeric MOD numeric     (modulo operator)

numeric numeric + numeric    (addition)

numeric - numeric    (subtraction)

string concatenation operator
logical
  • value EQ value
  • value NE value
  • value GT value
  • value LE value
  • value LT value
  • value GE value
  • value IN set
  • value NOT IN set
  • value BETWEEN value AND value
  • character value LIKE character value
logical NOT logical
logical logical AND logical
lowest logical logical OR logical