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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-03-24 : 07:38:24
|
| Jeff writes "I need to calculate a shipping and handling (S&H) charge to be assessed on each pick ticket that is generated in our ERP system. The S&H amount is a percentage of the pick ticket value (sql column extended_price). The percentages are as follows;0 - 499.99 2.25%500 - 1099.99 1.75%1100 - 1599.99 1.5%1600 - 2099.99 1.45%2100 + 1.3%I'd like to put the result of the above formula into a new column "insurance" in my view. I'm able to write extended_price * 0.0225 AS insurance and return a new column and value into my view, but I'm not sure how to write the conditional code described above (I've tried using the CASE expression in the select section of the query but am returned numerous SQL errors). We're on Windows 2000 / SQL Server 2000." |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-03-24 : 07:41:15
|
| This should work:...CASE WHEN extended_price<500 THEN 0.0225WHEN extended_price<1100 THEN 0.0175WHEN extended_price<1600 THEN 0.0150WHEN extended_price<2100 THEN 0.0145ELSE 0.0130 END AS Insurance |
 |
|
|
|
|
|