Error 149

Message text

Function or column reference to '%1' in the select list must also appear in a GROUP BY

Item

Value

SQLCode

-149

Constant

SQLE_INVALID_GROUP_SELECT

SQLState

53003

ODBC State

42000

Parameter 1

name of the column referenced directly, or in an expression, that must be in the GROUP BY clause

Probable cause

In a query using GROUP BY, select list items that are not aggregate functions must also appear in the GROUP BY clause. If the select list item is a column reference or an alias, simply add the column name or alias to the GROUP BY clause. If the select list item is a scalar function, ensure that the function's arguments in the GROUP BY clause match exactly with those in the select list. In some cases, you may want to use the MAX function on the column name (or another aggregate function) instead of adding the column to the GROUP BY clause.