17.10 - Example of numeric_factor - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Date and Time Functions and Expressions

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1211-171K
Language
English (United States)

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'.