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.
Author |
Topic |
jylland
Starting Member
27 Posts |
Posted - 2012-12-05 : 12:56:52
|
hi I have problem SELECT SUM(value) AS Totalos then I want validation of the TotalIf Totalos > 0 then 0else (totalos-100) end AS Price FROM dbo.database where......But how do I do this with a case statement ? |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-12-05 : 13:05:15
|
[code]SELECT CASE WHEN Totalos > 0 THEN 0 ELSE (totalos-100) END AS PriceFROM dbo.database[/code]BTW, "database" is not really a good name for a table. If you do choose to use it, use it like dbo.[database] |
 |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2012-12-05 : 13:08:45
|
quote: Originally posted by jylland hi I have problem SELECT SUM(value) AS Totalos from tabel where .... then I want validation of the TotalIf Totalos > 0 then 0else (totalos-100) end AS Price FROM dbo.database where......But how do I do this with a case statement ?
Case When SUM(Values) > 0 then 0 Else SUM(Values)- 100 End |
 |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-12-05 : 13:10:21
|
What sodeep said. I didn't read the question properly. |
 |
|
jylland
Starting Member
27 Posts |
Posted - 2012-12-05 : 18:38:21
|
quote: Originally posted by sunitabeck
SELECT CASE WHEN Totalos > 0 THEN 0 ELSE (totalos-100) END AS PriceFROM dbo.database BTW, "database" is not really a good name for a table. If you do choose to use it, use it like dbo.[database]
Great thanks |
 |
|
jylland
Starting Member
27 Posts |
Posted - 2012-12-05 : 18:40:13
|
quote: Originally posted by sodeep
quote: Originally posted by jylland hi I have problem SELECT SUM(value) AS Totalos from tabel where .... then I want validation of the TotalIf Totalos > 0 then 0else (totalos-100) end AS Price FROM dbo.database where......But how do I do this with a case statement ?
Case When SUM(Values) > 0 then 0 Else SUM(Values)- 100 End Thanks very much great
Thanks very much great |
 |
|
|
|
|