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
 General SQL Server Forums
 New to SQL Server Programming
 Error in group by clause

Author  Topic 

jim_jim
Constraint Violating Yak Guru

306 Posts

Posted - 2013-04-24 : 10:21:50
Hi All
how to solve for the error i have been getting when using group by clause for the below query .What am i doing wrong?

SELECT RR.REQUESTID,count(CD.totalsubs) as Subscribers,count(CD.Totalmem) as Members,RD.rptdesctext,Recp.emailadr
FROM report_request RR inner join Selected_report SR on RR.requestid = SR.requestid inner join REport_description RD on SR.rptdesc = RD.rptdesc inner join Recepients Recp on RR.requestid = Recp.requestid inner join customer_detail CD on RR.MSGN = Cd.msgn
where SR.completeddt between '1/1/2012' and '12/31/2012'
and RR.reportfrequency != 'One Time'
group by
RR.REQUESTID,count(CD.totalsubs),count(CD.Totalmem),RD.rptdesctext,Recp.emailadr


Error Message
Cannot use an aggregate or a subquery in an expression used for the group by list of a GROUP BY clause.

Thanks

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2013-04-24 : 10:34:38
quote:
Originally posted by jim_jim

Hi All
how to solve for the error i have been getting when using group by clause for the below query .What am i doing wrong?

SELECT RR.REQUESTID,count(CD.totalsubs) as Subscribers,count(CD.Totalmem) as Members,RD.rptdesctext,Recp.emailadr
FROM report_request RR inner join Selected_report SR on RR.requestid = SR.requestid inner join REport_description RD on SR.rptdesc = RD.rptdesc inner join Recepients Recp on RR.requestid = Recp.requestid inner join customer_detail CD on RR.MSGN = Cd.msgn
where SR.completeddt between '1/1/2012' and '12/31/2012'
and RR.reportfrequency != 'One Time'
group by
RR.REQUESTID,count(CD.totalsubs),count(CD.Totalmem),RD.rptdesctext,Recp.emailadr


Error Message
Cannot use an aggregate or a subquery in an expression used for the group by list of a GROUP BY clause.

Thanks



Cheers
MIK
Go to Top of Page

jim_jim
Constraint Violating Yak Guru

306 Posts

Posted - 2013-04-24 : 11:28:45
Thank You
Go to Top of Page
   

- Advertisement -