日期:2014-05-18  浏览次数:20681 次

来接下分---->轻松下~~~~
我吐血````前段时间有个”高“人走人```他写的东西我接手``发个经典的视图给你们看下```一点文档都没留下...不知道从哪里下手改```简直是砸我饭碗.哎``
create   or   replace   view   elappadm.v_empl_money   as select   Pay_type,employees_id,class_id,money,Month   from (select   '0 '   Pay_type,a.employees_id,a.class_id, decode(c.Fixed,1, decode(a.money*decode(d.native_wb,1,Total_coefficient*b.Personal_rate,b.total_wrate*b.personal_wrate),null,a.money,a.money*decode(d.native_wb,1,Total_coefficient*b.Personal_rate,b.total_wrate*b.personal_wrate)), -decode(a.money*decode(d.native_wb,1,Total_coefficient*b.Personal_rate,b.total_wrate*b.personal_wrate),null,a.money,a.money*decode(d.native_wb,1,Total_coefficient*b.Personal_rate,b.total_wrate*b.personal_wrate))) as   money, ' '   as   month   from   t_al_welfare   a,T_Insurance_class   b,v_xcfl_class   c,t_employees   d where   a.class_id=b.Class_Id(+) and   a.class_id   not   in( 'A-01 ',   'A-02 ', 'A-03 ', 'A-04 ', 'A-05 ') and   (a.class_id=c.Class_Id   or   b.class_id=c.Class_Id)   and   d.employees_id=a.employees_id union select   pay_type,employees_id,class_id,-sum(money)   as   money,month   from   (select   '1 '   Pay_type,employees_id   , 'A-03 '   class_id,Punish_money   money,Kq_Month   as   month from   T_Kq_hz)   group   by   pay_type,employees_id,class_id,month union select   '0 '   Pay_type,Employees_id, 'A-01 '   Class_id,Pay_money   as   money, ' '   as   month   from   T_Employees   a,T_Pay_class   b   where   a.PAY_ID=b.PayClass_id union select   '1 '   Pay_type,q.employees_id, 'A-02 '   as   Class_id,q.money*decode(w.bonus_rate,null,1,w.bonus_rate)   money, q.month   from   (select   m.employees_id,m.money,m.month,n.deptid   as   tdeptid   from   v_bonus_money   m,t_employees   n where   n.employees_id=m.employees_id   )   q,T_Bonus_rate   w   where   w.ydate(+)=q.month   and   w.deptid(+)=q.tdeptid   union   select   '0 '   Pay_type,b.employees_id, 'A-05 '   Class_id,(b.Work_years*a.SUBVENTION_JE)as   money, ' 'as   month   from   T_Employ_Class   a,t_employees   b   where   b.Emp_classID=a.emp_classid   and   b.work_years <=a.max_year) union select   '1 '   Pay_type,g.work_num   as   employees_id, 'A-04 ',g.price*h.fini_num   as   money,to_char(h.writ_time, 'yyyymm ')   as   month   from   (select   f.PRICE,e.seqn_num,e.Work_num   from   t_prod_proc   f, (select   m.seqn_num,m.Bill_id,m.Proc_id,m.seq,m.Work_num,n.PROD_CODE   from   T_task_dist   m,(select   b.PROD_CODE,a.bill_id   from   t_prod_info   a,v_t_bom_base   b   where   a.bom_id=b.bom_id)   n   where   m.bill_id=n.bill_id   and   m.dist_type= '1 ' union select   c.seqn_num,c.Bill_id,c.Proc_id,c.seq,d.g_manger   as   work_num,c.PROD_CODE   from   (select   m.seqn_num,m.Bill_id,m.Proc_id,m.seq,m.Work_num,n.PROD_CODE   from   T_task_dist   m,(select   b.PROD_CODE,a.bill_id   from   t_prod_info   a,v_t_bom_base   b   where   a.bom_id=b.bom_id)   n   where   m.bill_id=n.bill_id   and   m.dist_type= '2 ')c,t_group   d   where   c.Work_num=d.group_id)e where   f.Proc_id=e.Proc_id   and   f.seq=e.seq   and