KB Issue
Must declare the scalar variable "@P1GROUP" happens when you have a Column Name that is not listed in Statement.
Issue Details
When editing your SQL Script, you might misname your column or, in this case, move the Question Mark against another object in the statement.
Recreate Issue
In this case, I moved the '?' against the [Group] in [Group by].

Select Col1, Col2 from Table1 where Col3=?Group By Col1, Col2, Col3
Copy
Search Site
Search Google


As you can see in the Select Statement above, the ?Group
Copy
Search Site
Search Google
is against each other, causing this to become a single Variable in the Statement.
Resolve Issue
To 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
Copy
Search Site
Search Google