The following example uses an interval_term value divided by a numeric_factor value.
SELECT INTERVAL '10-03' YEAR TO MONTH / 3;
The interval_term is INTERVAL '10-03' YEAR TO MONTH.
The numeric_factor is 3.
The processing involves the following stages:
- The interval value is decomposed into a value of months.
Ten years and three months evaluate to 123 months.
- The interval total is divided by the numeric_factor 3, giving '3-05'.
The next example is similar to the first except that it shows how truncation is used in integer arithmetic.
SELECT INTERVAL '10-02' YEAR TO MONTH / 3;
The interval_term is INTERVAL '10-02' YEAR TO MONTH.
The numeric_factor is 3.
The processing involves the following stages:
- The interval value is decomposed into a value of months.
Ten years and two months evaluate to 122 months.
- The interval total is divided by the numeric_factor 3, giving 40.67 months, which is truncated to 40 because the value is an integer.
- The interval total is converted back to the appropriate format, giving INTERVAL '3-04'.