设为首页 加入收藏

TOP

Oracle function个人所得税
2014-11-24 07:39:14 来源: 作者: 【 】 浏览:2
Tags:Oracle function 个人所得税

起征税3000


Sql代码
create or replace function tax(v_salary in number) return number is
v_expense number;
--本级速算扣除额=上一级最高所得额×(本级税率-上一级税率)+上一级速算扣除数
v_quick_deduction number := 0;
v_temp number;
begin
v_temp := v_salary - 3000;
if v_temp <= 1500 then
v_temp := v_temp * 0.05;
elsif v_temp > 1500 and v_temp <= 4500 then
v_temp := v_temp * 0.1;
v_quick_deduction := 1500*(0.1-0.05) + 0;
elsif v_temp > 4500 and v_temp <= 9000 then
v_temp := v_temp * 0.2;
v_quick_deduction := 4500*(0.2-0.1) + 1500*(0.1-0.05);
elsif v_temp > 9000 and v_temp <= 35000 then
v_temp := v_temp * 0.25;
v_quick_deduction := 9000*(0.25-0.2) + 4500*(0.2-0.1) ;
elsif v_temp > 35000 and v_temp <= 55000 then
v_temp := v_temp * 0.3;
v_quick_deduction := 35000*(0.3-0.25) + 9000*(0.25-0.2);
elsif v_temp > 55000 and v_temp <= 80000 then
v_temp := v_temp * 0.35;
v_quick_deduction := 55000*(0.35-0.3) + 35000*(0.3-0.25);
elsif v_temp > 80000 then
v_temp := v_temp * 0.45;
v_quick_deduction := 80000*(0.45-0.35) + 55000*(0.35-0.3);
else
dbms_output.put_line(进来就不收你钱!);
v_temp := 0;
end if;
v_expense := v_temp - v_quick_deduction;
return(v_expense);
end tax;

create or replace function tax(v_salary in number) return number is
v_expense number;
--本级速算扣除额=上一级最高所得额×(本级税率-上一级税率)+上一级速算扣除数
v_quick_deduction number := 0;
v_temp number;
begin
v_temp := v_salary - 3000;
if v_temp <= 1500 then
v_temp := v_temp * 0.05;
elsif v_temp > 1500 and v_temp <= 4500 then
v_temp := v_temp * 0.1;
v_quick_deduction := 1500*(0.1-0.05) + 0;
elsif v_temp > 4500 and v_temp <= 9000 then
v_temp := v_temp * 0.2;
v_quick_deduction := 4500*(0.2-0.1) + 1500*(0.1-0.05);
elsif v_temp > 9000 and v_temp <= 35000 then
v_temp := v_temp * 0.25;
v_quick_deduction := 9000*(0.25-0.2) + 4500*(0.2-0.1) ;
elsif v_temp > 35000 and v_temp <= 55000 then
v_temp := v_temp * 0.3;
v_quick_deduction := 35000*(0.3-0.25) + 9000*(0.25-0.2);
elsif v_temp > 55000 and v_temp <= 80000 then
v_temp := v_temp * 0.35;
v_quick_deduction := 55000*(0.35-0.3) + 35000*(0.3-0.25);
elsif v_temp > 80000 then
v_temp := v_temp * 0.45;
v_quick_deduction := 80000*(0.45-0.35) + 55000*(0.35-0.3);
else
dbms_output.put_line(进来就不收你钱!);
v_temp := 0;
end if;
v_expense := v_temp - v_quick_deduction;
return(v_expense);
end tax;测试: select tax(5000) from dual;

结果:125

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇硬盘写满后redis的处理机制 下一篇oracle优化器以及SQL共享

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·C++ Lambda表达式保 (2025-12-26 05:49:45)
·C++ Lambda表达式的 (2025-12-26 05:49:42)
·深入浅出 C++ Lambda (2025-12-26 05:49:40)
·C语言指针从入门到基 (2025-12-26 05:21:36)
·【C语言指针初阶】C (2025-12-26 05:21:33)