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:
- The interval_primary is converted to an exact numeric, or 60 days.
- The operations indicated in the arithmetic are performed on the operands (which are both numeric at this point), 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.
- The numeric result is converted back into the indicated INTERVAL type, DAY TO SECOND.