In this post, you’ll learn about the error message -815 a group by or having clause is implicitly or explicitly specified in an embedded select statement or a subquery of a basic predicate in the IBM DB2 database , the reason why it occurs along with the solution to fix it
IBM DB2 Error Message
-815 a group by or having clause is implicitly or explicitly specified in an embedded select statement or a subquery of a basic predicate
Reason for the Error
An embedded SELECT statement or a subquery of a basic predicate either (1) directly contains a GROUP BY or HAVING clause, or (2) specifies as its object a view having a definition that includes a GROUP BY or HAVING clause.� Neither construct is permitted.
Solution
The implied function is not supported by DB2. In the case of a view, embedded SELECT statements cannot be used to retrieve data from that view. The SELECT INTO statement should be changed to� a DECLARE CURSOR statement in order to use the GROUP BY/HAVING.� In the case of the subquery, there is no coding workaround.� A GROUP BY/HAVING cannot be used within the subquery of a basic predicate because the subquery is allowed to return only a single value.� For more information on basic predicate refer to SQL Reference .