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 |
|
rookie_sql
Constraint Violating Yak Guru
443 Posts |
Posted - 2009-08-20 : 08:23:52
|
| Hi i've a a qty column which have negitave figures in it some times.Exampleqty Type 6 A 1 A 1 A 1 A 6 A-2 B-- 17 TotalNo you may think its strange to add the -2 but i do need to show thisnow do i get sql to add the -1 once the type column is set to B if i have a negative number. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-08-20 : 08:27:10
|
Did not get you.What is your problem / wanted output?Edit: What do you mean with "add the -1"? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2009-08-20 : 08:40:00
|
| select sum(abs(qty)) from tableselect sum(case when type='B' then -qtyelse qty ) from table |
 |
|
|
|
|
|