SQL Server Error : 164, Severity: 15. Each GROUP BY expression must contain at

SQL Server Error : 164 Details


SQL Server Error: 164
Severity: 15
Event Logged or not: No
Description:
Each GROUP BY expression must contain at least one column that is not an outer reference.
Severity 15 Description:
Indicates syntax errors in the Transact-SQL command.

Solution for Resolving the Error

SQL Server does not know positional arguments in group by part of the statement.

So, the column name needs repeatetion in group by part.

The positional syntax is  only permitted for order by like 1,2 etc.

In general it is better to use column names in the order by clause as well to be clear.

Some databases such as Postgres do support positional arguments for group by

SQL Server Error Code and solution summary


SQL Server Error: 164
Severity: 15
Event Logged or not: No
Description:
Each GROUP BY expression must contain at least one column that is not an outer reference.

The positional syntax is  only permitted for order by like 1,2 etc.

In general it is better to use column names in the order by clause as well to be clear.

 

Vamshi B

Share
Published by
Vamshi B

Recent Posts

sql server detected logical consistency based error

Learn about SQL Server detecting logical consistency based issues and how to resolve them.

5 months ago

sql server error 1222

Learn about SQL Server error 1222 and how to resolve the lock request time out…

5 months ago

Microsoft SQL Server 2022 New Features

Discover the new features of Microsoft SQL Server 2022 and how they compare to previous…

5 months ago

SQL Server Error 1222 lock request time out period exceeded

SQL Server Error 1222 lock request time out period exceeded   Lock request time out…

6 months ago

SQL Server Error : 427, Severity: 20. Could not load the definition for constr

SQL Server Error : 427, Severity: 20. Could not load the definition for constraint ID…

10 months ago

SQL Server Error : 204, Severity: 20. Normalization error in node %ls.

SQL Server Error : 204, Severity: 20. Normalization error in node %ls.

10 months ago

This website uses cookies.