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)
 SQL "CASE" Help

Author  Topic 

direrayne
Starting Member

30 Posts

Posted - 2011-01-05 : 20:00:03
i have a query with the following case statement.

SUM(CASE WHEN Department = 'SOUH' THEN TrxFullPrice
ELSE 0
END) AS SOUH


i need to add multiple departments however i cannot get it to work.
something like this.

SUM(CASE WHEN Department = 'SOUH', 'DIAM', 'JEWR' THEN TrxFullPrice
ELSE 0
END) AS SOUH


can someone please let me know if this is possible?
or provide a workaround?

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-01-05 : 20:05:16
SUM(CASE WHEN Department in ('SOUH', 'DIAM', 'JEWR') THEN TrxFullPrice
ELSE 0
END) AS SOUH




==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

direrayne
Starting Member

30 Posts

Posted - 2011-01-05 : 21:03:04
quote:
Originally posted by nigelrivett

SUM(CASE WHEN Department in ('SOUH', 'DIAM', 'JEWR') THEN TrxFullPrice
ELSE 0
END) AS SOUH




==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.



YES !!! thats it thank you very much.
Go to Top of Page
   

- Advertisement -