Neoview SQL Reference Manual (R2.5)

Interval Value Expressions
“Considerations for Interval Value Expressions”
“Examples of Interval Value Expressions”
The operands of an interval value expression can be combined in specific ways with addition
and subtraction operators. In this syntax diagram, the data type of a datetime expression is DATE,
TIME, or TIMESTAMP; the data type of an interval term or expression is INTERVAL.
interval-expression is:
interval-term
| interval-expression + interval-term
| interval-expression - interval-term
| (datetime-expression - datetime-primary)
[interval-qualifier]
interval-term is:
interval-factor
| interval-term * numeric-factor
| interval-term / numeric-factor
| numeric-term * interval-factor
interval-factor is:
[+|-] interval-primary
interval-primary is:
interval-literal
| column-reference
| interval-type-host-variable
| dynamic-parameter
| aggregate-function
| sequence-function
| scalar-subquery
| CASE-expression
| CAST-expression
| (interval-expression)
| OLAP-window-function
numeric-factor is:
[+|-] numeric-primary
| [+|-] numeric-primary ** numeric-factor
Interval value expressions are built from operands that can be:
Integers
Datetime value expressions
Interval literals
Column references with datetime or interval values
OLAP window functions
Dynamic parameters
Datetime or interval value functions
Aggregate functions, sequence functions, scalar subqueries, CASE expressions, or CAST
expressions that return interval values
For interval-term, datetime-expression, and datetime-primary, see “Datetime Value
Expressions” (page 257).
If the interval expression is the difference of two datetime expressions, by default, the result is
expressed in the least significant unit of measure for that interval. For date differences, the interval
is expressed in days. For timestamp differences, the interval is expressed in fractional seconds.
If the interval expression is the difference or sum of interval operands, the interval qualifiers of
the operands are either year-month or day-time. If you are updating or inserting a value that is
Expressions 261