Oracle function Personal Income Tax

Source: Internet
Author: User

Tax initiation: 3000


SQL code
Create or replace function tax (v_salary in number) return number is
V_expense number;
-- Deduction for quick calculation at this level = maximum income at the upper level × (current tax rate-higher tax rate) + deduction for quick calculation at the upper level
V_quick_deduction number: = 0;
V_temp number;
Begin
V_temp: = Vanderbilt 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 & gt; 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 (you will not be charged if you come in !);
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;
-- Deduction for quick calculation at this level = maximum income at the upper level × (current tax rate-higher tax rate) + deduction for quick calculation at the upper level
V_quick_deduction number: = 0;
V_temp number;
Begin
V_temp: = Vanderbilt 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 & gt; 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 (you will not be charged if you come in !);
V_temp: = 0;
End if;
V_expense: = v_temp-v_quick_deduction;
Return (v_expense );
End tax; test: select tax (5000) from dual;

Result: 125

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.