insert 税率表 select
1, 2000, 0 , 1000 , 0.05
union all select
2, 2000, 1000 , 3000 , 0.1
union all select
3, 2000, 3000 , 6000 , 0.15
union all select
4, 2000, 6000 , 10000 , 0.2
union all select
5, 2000, 10000, 15000 , 0.25
go
create proc pr_计算税金
@income numeric(18,2)
as
select sum(case when @income>baseIncome+overmax then overmax-overmin else @income-baseIncome-overmin end *taxs) as 税金
from 税率表
where baseIncome+overmin<=@income