-214 AN EXPRESSION IN THE FOLLOWING POSITION, OR STARTING WITH position-or-expression-start IN THE clause-type CLAUSE IS NOT VALID. REASON CODE = reason-code
Explanation
The expression identified by the first part of
the expression expression-start in the clause-type clause
is not valid for the reason specified by the reason-code as
follows:
- 1
- The fullselect of the select-statement is not a subselect. Expressions are not allowed in the ORDER BY clause for this type of select-statement. This reason code occurs only when clause-type is ORDER BY.
- 2
- DISTINCT is specified in the SELECT clause, and either a column name in the ORDER BY clause cannot be matched exactly with a column name in the select list, or a sort-key-expression is specified in the ORDER BY clause. This reason code occurs only when clause-type is ORDER BY.
- 3
- The select list includes an aggregate function or the subselect includes a GROUP BY clause and the expression is not an aggregate function or does not match exactly with an expression in the select list.
- 4
- Grouping is caused by the presence of an aggregate function in the ORDER BY clause. This reason code occurs only when clause-type is ORDER BY.
- 5
- Expression in a GROUP BY clause cannot contain a scalar-fullselect. This reason code occurs only when clause-type is GROUP BY.
- 6
- Invalid use of scalar-fullselect. This reason code can be issued when the scalar-fullselect appears in an ORDER BY clause, the RETURN statement of an SQL function contains a scalar-fullselect, or a scalar-fullselect is passed as an argument on a CALL statement for a parameter that is defined as an input parameter (IN).
System action
The statement cannot be processed.
Programmer response
Modify the select-statement based on the
reason specified by the reason-code. Use the following
suggestions to modify the select-statement:
- 1
- Remove the expression from the ORDER BY clause. If attempting to reference a column of the result, change the sort key to the simple-integer or simple-column-name form. For more information, see the ORDER BY syntax diagram in order-by-clause.
- 2
- Remove DISTINCT from the SELECT clause.
- 3
- Change the expression in the ORDER BY or GROUP BY clause to an aggregate function or change the clause to use a numeric column identifier or a column name.
- 4
- Add a GROUP BY clause or remove the aggregate function from the ORDER BY clause.
- 5
- Remove the scalar fullselect from the GROUP BY clause.
- 6
- Remove the scalar fullselect from the statement.
SQLSTATE
42822