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 |
|
brendalisalowe
Constraint Violating Yak Guru
269 Posts |
Posted - 2004-08-11 : 10:51:09
|
| I need an equation to change percentages according to what a certain amount is. I have this equation, but it doesn't work:UPDATE tblHUDdata SET RateCharged = 0.18WHERE RefundAmount > 2500ORSET RateCharged = 0.21WHERE RefundAmount BETWEEN 1800 AND 2500ORSET RateCharged = 0.23WHERE RefundAmount BETWEEN 1200 AND 1800ORSET RateCharged = 0.28WHERE RefundAmount BETWEEN 600 AND 1200ORSET RateCharged = 0.32WHERE RefundAmount < 600Any ideas? Thanks!Brenda |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-08-11 : 10:57:04
|
| try using case:case when RefundAmount > 2500 then 0.18 when RefundAmount BETWEEN 1800 AND 2500 then 0.21 ...endGo with the flow & have fun! Else fight the flow :) |
 |
|
|
brendalisalowe
Constraint Violating Yak Guru
269 Posts |
Posted - 2004-08-11 : 11:17:16
|
| What is wrong with this now?UPDATE tblHUDdata SET RateChargedCASE WHEN RefundAmount > 2500 THEN 0.18WHEN RefundAmount BETWEEN 1800 AND 2500 THEN 0.21WHEN RefundAmount BETWEEN 1200 AND 1800 THEN 0.23WHEN RefundAmount BETWEEN 600 AND 1200 THEN 0.28WHEN RefundAmount < 600 THEN 0.32ENDThanks for any help!Brenda |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-08-11 : 11:18:54
|
| you're missing an = signUPDATE tblHUDdata SET RateCharged =CASE WHEN RefundAmount > 2500 THEN 0.18...Go with the flow & have fun! Else fight the flow :) |
 |
|
|
brendalisalowe
Constraint Violating Yak Guru
269 Posts |
Posted - 2004-08-11 : 11:21:00
|
| Thanks a bunch! It works! yeah!Brenda |
 |
|
|
|
|
|