应发工资 > 1300 元部分开始计算所得税
                       0~ 1300 不用缴税
1300 ~ 1800 按 工资 * 5% -65
1300 ~ 3300 按 工资 * 10% -155
1300 ~ 6300 按 工资 * 15% -320
需求是这样子的,
我的表示这样子的
 工资下限,工资上限,扣除数,税率     0.00        1300.00     0.00     0.00
1300.00       1800.00    65.00     0.05
1300.00        3300.00  155.00    0.10
1300.00        6300.00   320.00    0.15求大神教导,写个存储过程,我传入一个工资进去怎么判断传入的工资属于哪个区间,多谢!求详细!

解决方案 »

  1.   


    --大概就是这个样子,自已改下就可以了
    create or replace procedure p_t(p_sal number)
    as
    v_shangxian number;
    v_xiaxian number;
    v_kouchushu number;
    v_tax number;
    begin
    execute immediate 'select 工资下限,工资上限,扣除数,税率 from 你的表 where :1 between 工资下限 and 工资上限'
    into v_shangxian,v_xiaxian,v_kouchushu,v_tax
    using p_sal;
    dbms_output.put_line(v_shangxian);
    end;
    /
      

  2.   

    declare 
      -- Local variables here
      i integer;
    begin
      if i-1300<0 then 
       dbms_output.put_line('no');
       return;
      end if;
      for item in (select * from 表) loop
          if item.上限-i>=0 then
            dbms_output.put_line('按这个标准交');
            return;
          end if;
      end loop;
    end;我给你写了个匿名块,按照这个根据你的情况修改就好了
      

  3.   

    他的下限都是一样的between and不好用
      

  4.   

    我觉得这个是对的,我Oracle太菜了,我看看这个循环怎么弄到proc里面
      

  5.   

    declare 
      -- Local variables here
      i integer;
    begin
      if i-1300<0 then 
       dbms_output.put_line('no');
       return;
      end if;
      for item in (select * from 表) loop
          if item.上限-i>=0 then
            dbms_output.put_line('按这个标准交');
            return;
          end if;
      end loop;
    end;
      

  6.   

    发现不对啊 。判断调教 item.上限-i>0会查出多个结果, 
      

  7.   

    我只找第一个符合item.上限-i>0,这个就是符合你的范围的,取了之后跳出循环就好了