KB IssueMust declare the scalar variable "@P1GROUP" happens when you have a Column Name that is not listed in Statement.
Issue DetailsWhen editing your SQL Script, you might misname your column or, in this case, move the Question Mark against another object in the statement.
Recreate IssueIn this case, I moved the '?' against the [Group] in [Group by].
Select Col1, Col2 from Table1 where Col3=?Group By Col1, Col2, Col3
As you can see in the Select Statement above, the ?Group is against each other, causing this to become a single Variable in the Statement.
Resolve IssueTo resolve this issue, place a space between your Variable and the Group By.
Select Col1, Col2 from Table1 where Col3=? Group By Col1, Col2, Col3