参数为:应税工资
create or replace function fun_salary_tax(taxable_salary number) return number is
functionresult number;
begin
functionresult := 0;
if taxable_salary > 80000 then
functionresult := (taxable_salary - 80000) * 0.45 + (80000 - 55000) * 0.35 + 13745;
elsif taxable_salary > 55000 then
functionresult := (taxable_salary - 55000) * 0.35 + (55000 - 35000) * 0.30 + 7745;
elsif taxable_salary > 35000 then
functionresult := (taxable_salary - 35000) * 0.30 + (35000 - 9000) * 0.25 + 1245;
elsif taxable_salary > 9000 then
functionresult := (taxable_salary - 9000) * 0.25 + (9000 - 4500) * 0.2 + 345;
elsif taxable_salary > 4500 then
functionresult := (taxable_salary - 4500) * 0.2 + (4500 - 1500) * 0.1 + 45;
elsif taxable_salary > 1500 then
functionresult := (taxable_salary - 1500) * 0.1 + 1500 * 0.03;
else
functionresult := taxable_salary * 0.03;
end if;
return(functionresult);
end fun_salary_tax;