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
 Site Related Forums
 Article Discussion
 Article: Aggregating Correlated Sub-Queries
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AskSQLTeam
Ask SQLTeam Question

USA
0 Posts

Posted - 10/23/2007 :  07:38:30  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote

Every now and then you may attempt to calculate an aggregate function -- such as SUM() -- on a correlated subquery, only to encounter the following error:



Msg 130, Level 15, State 1, Line 24
Cannot perform an aggregate function on an expression containing an aggregate or a subquery.

This can be a tricky situation to resolve depending on how your query is structured and how complicated it is, but here's a couple of ideas to help you out.



Read Aggregating Correlated Sub-Queries

NewGuy22
Starting Member

1 Posts

Posted - 11/08/2007 :  12:45:39  Show Profile  Reply with Quote
Jeff, I enjoy your articles. But this article, i donot know which database you used for sample queries.
I have AdventureWorks, Northwind and Pubs. I could not experiment queries in this article. Thanks Jeff
Go to Top of Page

nathans
Aged Yak Warrior

USA
933 Posts

Posted - 11/09/2007 :  01:56:16  Show Profile  Reply with Quote
Hi NewGuy22,
I think the code samples Jeff featured in his article were referencing mock tables to illustrate his point (Jeff, please correct me if im wrong and such sample db exists). YourTable and SomeTable are most likely just placeholders.

If you need help getting some sample data / tables please post back and we can help you out.

Nathan Skerl
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.2 seconds. Powered By: Snitz Forums 2000