Result Data Type - Advanced SQL Engine - Teradata Database

SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-30
dita:mapPath
tpt1555966086716.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1145
lifecycle
previous
Product Category
Teradata Vantage™

The following table shows the result data type for binary arithmetic operators.

The result data type for binary arithmetic operations involving UDT operands is the same as the result data type for the predefined data types to which the UDTs are implicitly cast.

For details on the result data type for binary arithmetic operations involving DateTime and Interval types, see Arithmetic, Trigonometric, Hyperbolic Operators/Functions.

When the operand on the left is … And the operand on the right is … And the operator is … Then the result data type is …
any data type any data type ** FLOAT
DATE BYTEINT

SMALLINT

INTEGER

BIGINT

+ - DATE

If the value of a date result is not in the range of values allowed for the DATE type, an error is reported. The range is any date on the Gregorian calendar from year 1 to year 9999.

BYTEINT

SMALLINT

INTEGER

* / MOD INTEGER

These operations on DATE do not report an error, but results are generally not meaningful.

  BIGINT * / MOD BIGINT

These operations on DATE do not report an error, but results are generally not meaningful.

DECIMAL(k,j) + - DATE

These operations on DATE do not report an error, but results are generally not meaningful.

Fractions of decimal values are truncated when added to or subtracted from date values.

If the value of a date result is not in the range of values allowed for the DATE type, an error is reported. The range is any date on the Gregorian calendar from year 1 to year 9999.

* / MOD DECIMAL(p,j)

These operations on DATE do not report an error, but results are generally not meaningful.

For details about the value of p, see DECIMAL Result Data Type.

NUMBER(k,j)

NUMBER(k)

NUMBER(*,j)

NUMBER

+ - DATE

These operations on DATE do not report an error, but results are generally not meaningful.

Fractions of decimal values are truncated when added to or subtracted from date values.

If the value of a date result is not in the range of values allowed for the DATE type, an error is reported. The range is any date on the Gregorian calendar from year 1 to year 9999.

* / MOD NUMBER
FLOAT * / + - MOD FLOAT
DATE - INTEGER

The difference between two dates is the number of days between those dates. Note that this is not the numeric difference between the values.

+ * / MOD INTEGER

These operations on DATE do not report an error, but results are generally not meaningful.

CHAR(n)

VARCHAR(n)

* / + - MOD FLOAT

These operations on DATE do not report an error, but results are generally not meaningful.

If an argument of an arithmetic operator is a character string, the first action is to attempt to convert the character string to a floating value. If this conversion fails, an error is reported.

BYTEINT

SMALLINT

INTEGER

BYTEINT

SMALLINT

INTEGER

* / + - MOD INTEGER
BIGINT * / + - MOD BIGINT
DECIMAL(k,j) * / + - MOD DECIMAL(p,j)

For details about the value of p, see DECIMAL Result Data Type.

NUMBER(k,j)

NUMBER(k)

NUMBER(*,j)

NUMBER

* / + - MOD NUMBER
FLOAT * / + - MOD FLOAT
CHAR(n)

VARCHAR(n)

* / + - MOD FLOAT

If an argument of an arithmetic operator is a character string, the first action is to attempt to convert the character string to a floating value. If this conversion fails, an error is reported.

DATE + DATE

If the value of a date result is not in the range of values allowed for the DATE type, an error is reported. The range is any date on the Gregorian calendar from year 1 to year 9999.

- error
* / MOD INTEGER

These operations on DATE do not report an error, but results are generally not meaningful.

BIGINT BYTEINT

SMALLINT

INTEGER

BIGINT

* / + - MOD BIGINT
DECIMAL(k,j) * / + - MOD DECIMAL(p,j)

For details about the value of p, see DECIMAL Result Data Type.

NUMBER(k,j)

NUMBER(k)

NUMBER(*,j)

NUMBER

* / + - MOD NUMBER
FLOAT * / + - MOD FLOAT
CHAR(n)

VARCHAR(n)

* / + - MOD FLOAT

If an argument of an arithmetic operator is a character string, the first action is to attempt to convert the character string to a floating value. If this conversion fails, an error is reported.

DATE + DATE

If the value of a date result is not in the range of values allowed for the DATE type, an error is reported. The range is any date on the Gregorian calendar from year 1 to year 9999.

- error
* / MOD BIGINT

These operations on DATE do not report an error, but results are generally not meaningful.

DECIMAL(m,n) BYTEINT

SMALLINT

INTEGER

BIGINT

+ - * DECIMAL(p,n)

For details about the value of p, see DECIMAL Result Data Type.

/ MOD DECIMAL(m,n)
DECIMAL(k, j) + - DECIMAL(min(p,(1+max(n,j)+max(m -n,k-j))),max(n,j))

For details about the value of p, see DECIMAL Result Data Type.

* DECIMAL(min(p,m +k),(n+j))

For details about the value of p, see DECIMAL Result Data Type.

/ MOD DECIMAL(p,max(n,j))

For details about the value of p, see DECIMAL Result Data Type.

NUMBER(k,j)

NUMBER(k)

NUMBER(*,j)

NUMBER

* / + - MOD NUMBER
FLOAT * / + - MOD FLOAT
CHAR(n)

VARCHAR(n)

* / + - MOD FLOAT

If an argument of an arithmetic operator is a character string, the first action is to attempt to convert the character string to a floating value. If this conversion fails, an error is reported.

DATE + DATE

Fractions of decimal values are truncated when added to or subtracted from date values.

If the value of a date result is not in the range of values allowed for the DATE type, an error is reported. The range is any date on the Gregorian calendar from year 1 to year 9999.

- error
* DECIMAL(p,n)

These operations on DATE do not report an error, but results are generally not meaningful.

For details about the value of p, see DECIMAL Result Data Type.

/ MOD DECIMAL(m,n)

These operations on DATE do not report an error, but results are generally not meaningful.

NUMBER(m,n)

NUMBER(m)

NUMBER(*,n)

NUMBER

BYTEINT

SMALLINT

INTEGER

BIGINT

* / + - MOD NUMBER
DECIMAL(k,j)
FLOAT * / + - MOD FLOAT
CHAR(n)

VARCHAR(n)

FLOAT

If an argument of an arithmetic operator is a character string, the first action is to attempt to convert the character string to a floating value. If this conversion fails, an error is reported.

DATE + DATE

Fractions of decimal values are truncated when added to or subtracted from date values.

If the value of a date result is not in the range of values allowed for the DATE type, an error is reported. The range is any date on the Gregorian calendar from year 1 to year 9999.

- error
* NUMBER

These operations on DATE do not report an error, but results are generally not meaningful.

/ MOD NUMBER

These operations on DATE do not report an error, but results are generally not meaningful.

  NUMBER(k,j)

NUMBER(k)

NUMBER(*,j)

NUMBER

* / + - MOD NUMBER
FLOAT BYTEINT

SMALLINT

INTEGER

BIGINT

DECIMAL(k,j)

NUMBER(k,j)

NUMBER(k)

NUMBER(*,j)

NUMBER

FLOAT

* / + - MOD FLOAT
DATE * / + - MOD FLOAT

These operations on DATE do not report an error, but results are generally not meaningful.

CHAR(n)

VARCHAR(n)

* / + - MOD FLOAT

If an argument of an arithmetic operator is a character string, the first action is to attempt to convert the character string to a floating value. If this conversion fails, an error is reported.

CHAR(n)

VARCHAR(n)

BYTEINT

SMALLINT

INTEGER

BIGINT

DECIMAL(k,j)

NUMBER(k,j)

NUMBER(k)

NUMBER(*,j)

NUMBER

FLOAT

CHAR(n)

VARCHAR(n)

* / + - MOD FLOAT

If an argument of an arithmetic operator is a character string, the first action is to attempt to convert the character string to a floating value. If this conversion fails, an error is reported.

DATE * / + - MOD FLOAT

These operations on DATE do not report an error, but results are generally not meaningful.

If an argument of an arithmetic operator is a character string, the first action is to attempt to convert the character string to a floating value. If this conversion fails, an error is reported.