As a Project Manager, it is not every day that I write SQL queries anymore. I was writing a query to select data for a client and I ran into the following error:

Each GROUP BY expression must contain at least one column that is not an outer reference

The following example is not the actual query I was using, but we will use this for demonstration purposes. The table I was selecting from contained only Full Time Employees’ (FTEs) certifications. I wanted a column to indicate that I was selecting from the FTE table versus another table. I added the string ‘FTE’ to my select query. When I went to do my GROUP BY statement I included all of the fields that were not aggregates. My SQL statement looked something similar to the following:

When I executed this select query I received the following error message:

Each GROUP BY expression must contain at least one column that is not an outer reference

The column SQL Management Studio was complaining about was my ‘FTE’ string, removing this column from the GROUP BY fixed my error.

 

Like this post? Share it!