Suppose you have a table 'tblTest' with column named 'Col1', 'Col2'.
And you have a parameter
Declare @param nvarchar(50)
Suppose you want to group by column with parameter.
Select @param as Parameter, Col1, Col2 , Count (Col1) from tblTest
group by @param, Col1, Col2
Above query will give error:
Using a parameter in Group by clause gives error "GROUP BY expression must contain at least one column that is not an outer reference"
Solution : You just remove @param from group by clause.
Select @param as Parameter, Col1, Col2 , Count (Col1) from tblTest
group by Col1, Col2
No comments:
Post a Comment