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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 Site Related Forums
 Article Discussion
 Article: Aggregating Correlated Sub-Queries
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Ask SQLTeam Question

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

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

Aged Yak Warrior

938 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  
 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.02 seconds. Powered By: Snitz Forums 2000