Example of numeric_factor - Advanced SQL Engine - Teradata Database

SQL Date and Time Functions and Expressions

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-27
dita:mapPath
dzx1591742169550.ditamap
dita:ditavalPath
dzx1591742169550.ditaval
dita:id
B035-1211
lifecycle
previous
Product Category
Teradata Vantageā„¢

This example uses a numeric_factor with an INTERVAL YEAR TO MONTH typed value.

SELECT INTERVAL '10-02' YEAR TO MONTH * 12/5;

The numeric_factor in this operation is the integer 12.

The processing involves the following stages:

  1. The interval is multiplied by 12, giving the result as an interval.
  2. The interval result is divided by 5, giving '24-04'.

Note that very different results are obtained by using parentheses to change the order of evaluation as follows.

SELECT INTERVAL '10-02' YEAR TO MONTH * (12/5);

The numeric_factor in this operation is (12/5).

The processing involves the following stages:

  1. The numeric_factor is computed, giving the result 2.4, which is truncated to 2 because the value is an integer by default.
  2. The interval is multiplied by 2, giving '20-04'.