Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

i have this query:

SELECT
SolutionName    -- Solution_NAM
from  Table_View
Group By 1

where Table_View is of course a view. I am gettign this error message:

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

Can you help me resolve this? It´s inside Ms SQL Server 2008

like image 775
Dantes Avatar asked Oct 04 '12 07:10

Dantes


People also ask

Can we select column which is not part of GROUP BY?

In MySQL, when you try to select a column that isn't used in the GROUP BY clause, or in an aggregate function inside the statement, it is not a valid statement according to SQL standard and will cause an error.

What is an outer reference in SQL?

An outer reference is a column name that does not refer to any of the columns in any of the tables in the FROM clause of the subquery. Instead, the column name refers to a column of a table specified in the FROM clause of the main query.

What does GROUP BY 1 do in SQL?

It means to group by the first column of your result set regardless of what it's called. You can do the same with ORDER BY .

Can we use GROUP BY without Where?

GROUP BY without Aggregate Functions Although most of the times GROUP BY is used along with aggregate functions, it can still still used without aggregate functions — to find unique records.


1 Answers

you cannot give Group by 1

try

SELECT
SolutionName    -- Solution_NAM
from  Table_View
Group By SolutionName
like image 155
Joe G Joseph Avatar answered Sep 25 '22 15:09

Joe G Joseph