4.4.19 Value expression

Organization of this subsection
(1) Format
(2) Function
(3) Operands
(4) Syntax rules
(5) Notes
(6) Usage example

(1) Format

value-expression::=[sign]term[operator[sign]term]...
   term::=[cast-specification]value-expression-primary
   operator::={+|-|*|/}
   sign::={+|-}
   cast-specification::={'('TINYINT')'|'('SMALLINT')'|'('INT[EGER]')'
                  |'('BIGINT')'|'('REAL')'|'('FLOAT')'|'('DOUBLE')'
                  |'('DEC[IMAL]')'}
   value-expression-primary::={column-specification|column-name|constant|'('value-expression')'}

(2) Function

Specifies a value.

(3) Operands

sign

Specify + or -.

term

Specify a value expression primary and, optionally, a cast specification.

cast specification

For details about the data types that can be specified for cast specification, see 3.3 CQL data types.

value expression primary

Specify a column specification, a column name, a constant, or a value expression.

column-specification
For details about column specifications, see 3.2.5(2) Column specification.
column-name
If the succeeding FROM clause only references a single relation, you can specify just a column name.
If the succeeding FROM clause references multiple relation, you must specify a column specification.
constant
For details about constants, see 4.4.20 Constant.

operator

Specify +, -, *, or /. When specifying a singed term after an operator, enclose the term in parentheses. Signs and operator examples follow:

-a+(-b)
a*(-b+1)
a/(-b)+1

(4) Syntax rules

(5) Notes

(6) Usage example

Outputs the values obtained by casting column a in relation s1 into DECIMAL data and column b into INT data. The underlined parts indicate value expressions.

REGISTER QUERY q1 SELECT (DECIMAL)s1.a AS xxx, (INT)s1.b AS yyy FROM s1[ROWS 100];