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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 sum a sum statement

Author  Topic 

emzzz
Starting Member

15 Posts

Posted - 2008-01-11 : 10:57:29
Hello,

I have a statement that returns a result set of summed results but I would like to sum the total of these results.

I have the following:
select sum(x) from y group by z

and I need:
select sum(select sum(x) from y group by z )

Many thanks!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-01-11 : 11:00:57
Try:-
select sum(a.t)
from
(
select sum(x) as t from y group by z
)a
Go to Top of Page

emzzz
Starting Member

15 Posts

Posted - 2008-01-11 : 11:01:42
Perfect, many thanks!
Go to Top of Page
   

- Advertisement -