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 2008 Forums
 Transact-SQL (2008)
 case statement with a select sum ?

Author  Topic 

jylland
Starting Member

27 Posts

Posted - 2012-12-10 : 11:44:29
is this here posible

How do I SUM(Values)- Select SUM(value2) as test

I have problem with "SUM(Values)- test"

My code

SELECT SUM(value) AS Totalos....
Case When SUM(Values) > 0 then 0 Else SUM(Values)- Select SUM(value2) as test from anothertable...


nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-12-10 : 12:32:38
you need an end

SELECT SUM(value) AS Totalos....
Case When SUM(Values) > 0 then 0 Else SUM(Values) end - Select SUM(value2) as test from anothertable...



==========================================
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

jylland
Starting Member

27 Posts

Posted - 2012-12-11 : 05:24:21
quote:
Originally posted by nigelrivett

you need an end

SELECT SUM(value) AS Totalos....
Case When SUM(Values) > 0 then 0 Else SUM(Values) end - Select SUM(value2) as test from anothertable...



==========================================
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.



Great job nigelrivett Thanks
Go to Top of Page
   

- Advertisement -