唉, 惆怅啊,大神救命

解决方案 »

  1.   

    查询的SQL语句:
    select  * 
    from  (select  a.charge_id,
    a.charge_name,
    d.division_name,
    e.dept_name,
    f.section_name,
    b.post_name,
    a.post_id,
    c.division_id,
    c.dept_id,
    c.section_id 
    from  charge_mst a left join post_mst b on a.post_id = b.post_id inner join cddsc_trn c on c.charge_id = a.charge_id left join division_mst d on c.division_id = d.division_id 
    and  c.division_id <> '0' left join dept_mst e on c.division_id = e.division_id 
    and  c.dept_id = e.dept_id 
    and  c.dept_id <> '0' left join section_mst f on c.division_id = f.division_id 
    and  c.dept_id = f.dept_id 
    and  c.section_id = f.section_id 
    and  c.section_id <> '0') as g 
    where  1=1 
      

  2.   


    select *  
    from (select IsNull(a.charge_id,0)as charge_id ,
    IsNull(a.charge_name,0)as charge_name,
    IsNull(d.division_name,0)as division_name,
    IsNull(e.dept_name,0)as dept_name,
    IsNull(f.section_name,0)as section_name,
    IsNull(b.post_name,0)as post_id,
    IsNull(a.post_id,0)as post_id,
    IsNull(c.division_id,0)as division_id,
    IsNull(c.dept_id,0)asdept_id,
    IsNull(c.section_id ,0)as  section_id
    from charge_mst a left join post_mst b on a.post_id = b.post_id inner join cddsc_trn c on c.charge_id = a.charge_id left join division_mst d on c.division_id = d.division_id  
    and c.division_id <> '0' left join dept_mst e on c.division_id = e.division_id  
    and c.dept_id = e.dept_id  
    and c.dept_id <> '0' left join section_mst f on c.division_id = f.division_id  
    and c.dept_id = f.dept_id  
    and c.section_id = f.section_id  
    and c.section_id <> '0') as g  
    where 1=1