Example: numeric_term * ± interval_primary - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

This example multiplies a negative interval_primary by a numeric_term and adds the negative result to an interval_term.

SELECT (RACE_DURATION + (2 * INTERVAL -'30' DAY));

The numeric_term is the numeric_primary 2.

The interval_primary is INTERVAL -'30' DAY.

RACE_DURATION is an interval_term, with type INTERVAL DAY TO SECOND.

The processing involves the following stages:

  1. The interval_primary is converted to an exact numeric, or 60 days.
  2. The operations indicated in the arithmetic are performed on the operands (which are both numeric now), producing an exact numeric result having the appropriate scale and precision.

    In this example, 60 days are subtracted from RACE_DURATION, which is an INTERVAL type of INTERVAL DAY TO SECOND.

  3. The numeric result is converted back into the indicated INTERVAL type, DAY TO SECOND.