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 2000 Forums
 Transact-SQL (2000)
 using several SUM's based on parameters

Author  Topic 

Guran
Starting Member

17 Posts

Posted - 2005-06-02 : 17:07:02
Is it possible to have two SUM's in the same SQL-statement, both of them summing the same column but they sum the in different ways.
Right now I do something like SELECT Clients.Name, SUM(TimeReports.Hours). By using a parameter under the WHERE part I can select Hours that are of one type. But I would like to get two sums. One of the hours that is part of type one and one that is part of type two. Like I said, getting one of them is no problem. The problem is getting both of them in the same statement.

Is it possible?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-06-02 : 17:10:21
Show us an example. Andy's solution might be what you are looking for though:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50613


Tara
Go to Top of Page
   

- Advertisement -