日期:2014-05-18 浏览次数:20532 次
-- 积分短为 col select (case when col <= 5000 then col when col > 5000 and col <= 30000 then 5000+(col-5000)*0.02 when col > 30000 and col <= 50000 then 5000+25000*0.02+(col-30000)*0.03 when ... end) from tb -- 类似写下去!
------解决方案--------------------
create table TB(积分 int) insert into TB select 67500 insert into TB select 125412 go select 积分, (case when 积分>5000 and 积分<=30000 then 积分*0.02 when 积分>30000 and 积分<=50000 then 600+(积分-30000)*0.03 when 积分>50000 and 积分<=100000 then 1200+(积分-50000)*0.04 when 积分>100000 then 2000+(积分-100000)*0.05 end)返还金额 from tb /* 积分 返还金额 ----------- --------------------------------------- 67500 1900.00 125412 3270.60 (2 行受影响) */ go drop table tb