SQL Guide : solidDB® SQL statements : Common clauses : expression
  
expression
Expression
 
expression
::= expression_item | expression_item { + | - | * | / } expression_item
Note Spaces on each side of the operator are optional.
expression_item
::= [ + | - ] { value | column_identifier | function | case_expression | cast_expression | ( expression ) }
value
::= literal | USER | variable
function
::= set_function | null_function | string_function |
numeric_function |
datetime_function | system_function |
datatypeconversion_function
Note The string, numeric, datetime, and datatype conversion functions are scalar functions in which an operation denoted by a function name is followed by a pair of parenthesis enclosing zero or more specified arguments. Each scalar function returns a single value.
set_function
::= COUNT (*) |
{ AVG | MAX | MIN | SUM |
COUNT }
( { ALL | DISTINCT }
expression )
null_function
::= { NULLVAL_CHAR( ) | NULLVAL_INT( ) }
datatypeconversion_function
::= CONVERT_CHAR(value_exp) | CONVERT_DATE(value_exp) | CONVERT_DECIMAL(value_exp) | CONVERT_DOUBLE(value_exp) | CONVERT_FLOAT(value_exp) | CONVERT_INTEGER(value_exp) | CONVERT_LONGVARCHAR(value_exp) | CONVERT_NUMERIC(value_exp) | CONVERT_REAL(value_exp) | CONVERT_SMALLINT(value_exp) | CONVERT_TIME(value_exp) | CONVERT_TIMESTAMP(value_exp) | CONVERT_TINYINT(value_exp) | CONVERT_VARCHAR(value_exp)
Note These functions are used to implement the {fn CONVERT(value, odbc_typename)} escape clauses defined by ODBC. However, you should use CAST(value AS sql_typename) which is defined in SQL-92 and fully supported by solidDB®.
case_expression
::= case_abbreviation | case_specification
case_abbreviation
::= NULLIF(value_exp, value_exp) | COALESCE(value_exp {, value_exp }...)
The NULLIF function returns NULL if the first parameter is equal to the second parameter; otherwise, it returns the first parameter. It is equivalent to IF (p1 = p2) THEN RETURN NULL ELSE RETURN p1; The NULLIF function is useful if you have a special value that serves as a flag to indicate NULL. You can use NULLIF to convert that special value to NULL. In other words, it behaves like IF (p1 = NullFlag) THEN RETURN NULL ELSE RETURN p1;
COALESCE returns the first non-NULL argument. The list of arguments may be of almost any length. All arguments should be of the same (or compatible) data types.
case_specification
::= CASE [value_exp]
WHEN value_exp
THEN {value_exp }
[WHEN value_exp
THEN { value_exp } ...]
[ELSE { value_exp }]
END
cast_expression
::= CAST (value_exp AS -data-type)
row value constructor expression
A row value constructor (RVC) is an ordered sequence of values delimited by parentheses, for example:
(1, 4, 9)
('Smith', 'Lisa')
A row construction is based on a series of elements/values, similar to a row of a table that is composed of a series of fields.
For more information about row value constructors, see Row value constructors.
See also
Common clauses