In this post, you’ll learn about the error message -122 a select statement with no group by clause contains a column name or a column function in the select clause or a column name is contained in the select clause but not in the group by clause in the IBM DB2 database , the reason why it occurs along with the solution to fix it
IBM DB2 Error Message
-122 a select statement with no group by clause contains a column name or a column function in the select clause or a column name is contained in the select clause but not in the group by clause
Reason for the Error
The SELECT statement contains one of these two types of errors:� *�� The statement contains a column name and a column function in the���� SELECT clause, but no GROUP BY clause.� *�� A column name is contained in the SELECT clause (possibly within a��� scalar function) but not in the GROUP BY clause.
Solution
You can correct the statement by:
Including the columns or expressions in the GROUP BY clause that are in the SELECT clause, or
Removing the columns or expressions from the SELECT clause.