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 |
Mhuff
Starting Member
5 Posts |
Posted - 2015-03-10 : 14:11:32
|
I don't think it is possible, but is there a way to doCASE WHEN [Amount] < '1' and [Quantity] <'1' THEN [Amount] * '-1' ELSE [Amount] ?The problem I am having is that some of the amounts were input correctly with negative numbers that have negative quantities associated with them. Others are incorrect and have negative quantities with positive numbers so if I try and manipulate it so that the data where there is negative quantities and I multiply the amounts then I will get those correct, but then it just made positive all of the other amounts that already had negative amounts.I also tried this and it doesn't work:CASE WHEN [Amount] < '0' THEN [Amount] * '-1'WHEN [Quantity] < '0' THEN [Amount] * '-1' ELSE [Amount] end, |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2015-03-10 : 14:24:07
|
this:CASE WHEN [Amount] < '1' and [Quantity] <'1' THEN [Amount] * '-1' ELSE [Amount] is valid, but:1. do not put 1 and -1 in quotes (they are numbers after all)2. what if amount is positive and quantity negative, or vice versa? |
|
|
Mhuff
Starting Member
5 Posts |
Posted - 2015-03-10 : 14:47:59
|
Sorry, I should have put:CASE WHEN [Amount] >0 and [Quantity] < 1 THEN [Amount] * -1 ELSE [Amount] I think that will leave all of the previous negatives alone and only multiply the ones that need to be negative. |
|
|
|
|
|