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.

 All Forums
 Site Related Forums
 Article Discussion
 Article: Aggregating Correlated Sub-Queries

Author  Topic 

Ask SQLTeam Question

0 Posts

Posted - 2007-10-23 : 07:38:30

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 Post

Posted - 2007-11-08 : 12:45:39
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 - 2007-11-09 : 01:56:16
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

- Advertisement -