Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Group By Error

Author  Topic 

Trudye
Posting Yak Master

169 Posts

Posted - 2008-05-08 : 09:56:38
Can anyone tell me why I'm getting this msg, or even tell me what it means;
Thanx,
Trudye

SELECT C.[TimeStamp] As [TimeStamp], CustName AS CustName,
LTRIM(RTrim([Phone])) AS Phone, FirstOfExplain_followup AS FirstOfExplain_followup,
RetailerName As RetailerName, Issue As Issue, FaxContact AS FaxContact,
ResultsKey As ResultsKey, Real_Client As Real_Client, D.callback As Callback,
@CboClient As CboClient, ResultsDepartment As ResultsDept, [Status] As [Status]
INTO tmpE_C_Report
FROM tmpE_C C
INNER JOIN tblEData D ON D.ResultsPKey = C.ResultsKey
GROUP BY C.Timestamp, [CustName],
Phone, FirstOfExplain_followup, RetailerName, Issue, FaxContact, C.ResultsKey,
Real_Client, callback, @CboClient, D.ResultsDepartment, [Status]

Msg 164, Level 15, State 1, Procedure Escalation_Callbacks_Rpt_5, Line 155
Each GROUP BY expression must contain at least one column that is not an outer reference.

Thanx,
Trudye

ayamas
Aged Yak Warrior

552 Posts

Posted - 2008-05-08 : 10:04:09
I guess "@CboClient" is causing an error as it an variable & cannot be used in a group by clause.
Try removing all the refrences of @CboClient from your query & try.
Go to Top of Page

Trudye
Posting Yak Master

169 Posts

Posted - 2008-05-09 : 08:33:49
You hit the nail on the head, that is exactly what the problem was. Now I know and will never forget that you CANNOT use a DECLARED variable in a Group By clause.

Thanks again ayamas,
Go to Top of Page

ayamas
Aged Yak Warrior

552 Posts

Posted - 2008-05-09 : 08:53:55
quote:
Originally posted by Trudye

You hit the nail on the head, that is exactly what the problem was. Now I know and will never forget that you CANNOT use a DECLARED variable in a Group By clause.

Thanks again ayamas,



Glad I could help
Go to Top of Page
   

- Advertisement -