logo  
Google
 

DB2 SQL-Error: -214

SQLState: 42822

Short Description: AN EXPRESSION IN THE FOLLOWING POSITION OR STARTING WITH IN THE CLAUSE IS NOT VALID REASON CODE

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 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 executed. Programmer response: Modify the select-statement based on the reason specified by the reason-code. Use one of the following suggestions to modify the select-statment: 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. See the ORDER BY syntax diagram in the DB2 SQL Reference for more information 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.

 <-  BACK TO INDEX