SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Error in group by clause
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jim_jim
Constraint Violating Yak Guru

USA
299 Posts

Posted - 04/24/2013 :  10:21:50  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Pakistan
1052 Posts

Posted - 04/24/2013 :  10:34:38  Show Profile  Reply with Quote
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

USA
299 Posts

Posted - 04/24/2013 :  11:28:45  Show Profile  Reply with Quote
Thank You
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000