计算个人所得税函数

-- =============================================

-- Author:    Maco_wang

-- Create date: 2011-03-<Create Date,,>

-- Description:   参考htl258(Tony)的思路,改写的计算个税的函数

-- =============================================

create function TaxRateOfPersonal

(

    @fvalue numeric(18,4)

)

returns numeric(18,4)

as

begin

    declare @i numeric(18,4)

    declare @basetable table(id int,

    basemoney numeric(18,4),minvalue numeric(18,4),

    maxvalue numeric(18,4),taxs numeric(18,4))

   

    insert into @basetable

    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

    select @i=sum(case when @fvalue>basemoney+maxvalue

    then maxvalue-minvalue else @fvalue-basemoney-minvalue end *taxs)

    from @basetable where basemoney+minvalue<=@fvalue

    return @i

end

 

--测试示例

select dbo.TaxRateOfPersonal(2500)

select dbo.TaxRateOfPersonal(3500)

select dbo.TaxRateOfPersonal(5000)

select dbo.TaxRateOfPersonal(9500)

 

--运行结果

/*

25.0000

100.0000

250.0000

1000.0000

*/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值