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 |
|
ukkz001
Starting Member
15 Posts |
Posted - 2006-04-05 : 12:29:08
|
| I am trying write a query to update a column of data in my xLegHdr table however the update is based on multiple criteria. I was trying to use "IF..ELSE" statements but that is not working.I would like to update the "SMiles" column based on the data in the "Dist" column. If the number in the "Dist" column is less than 250 then subtract 25 and multiply it by 1.15 the result should go in the "SMiles" column. If the number is grater than 250 then subtract 40 and multiply by 1.15 and place the result in the "SMiles" column; like so:UPDATE xLegHdrSET SMiles = IF Dist<250 THEN Round(Dist-25)*1.15) ELSE Round(Dist-40)*1.15)END IFAny ideas? |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-04-05 : 12:37:30
|
| UPDATE xLegHdrSET SMiles = case when Dist<250 THEN Round(Dist-25)*1.15)ELSE Round(Dist-40)*1.15)end==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|