select distinct
           r.Xingm     as 姓名,
           r.chushrq   as 出生日期,
           r.hukxzh    as 户口性质,
           po.xingm    as 姓名,
           po.chushrq  as 出生日期,
           po.hukxzh   户口性质,
           zn.xingm    as 姓名,
           zn.xingb    as 性别,
           zn.chushrq  as 出生日期,
           b.cuoshzhl  as 措施种类,
           b.biyqshshj as 时间,
           b.shishdw   as 地点,
           -- dsz.dushzhh     as 独生证号,
           --dsz.dushzhffshj as 领证时间,
           --(case when r.hujd=po.hujd then )
           t.jianglydje
      from (select * from pis_p_jiangybzh) t
      left join pis_p_renk r
        on t.renkid = r.sysid
       and t.juzhd = r.hujd
      left join pis_p_biysh b
        on r.sysid = b.renkid
      left join pis_c_cuoshzhl cc
        on cc.code = b.cuoshzhl
      left join pis_p_guanx g
        on g.renkid = r.sysid
       and g.guanxlx = 10
      left join pis_p_renk po
        on po.sysid = g.guanxrid
       and g.guanxlx = 10
       and t.juzhd = po.hujd
      left join pis_p_guanx gs
        on r.sysid = gs.renkid
      left join pis_p_renk zn
        on gs.guanxrid = zn.sysid
      left join pis_c_hukxzh c
        on c.code = r.hukxzh
      left join pis_c_hukxzh d
        on d.code = po.hukxzh
     where t.jianglydlx in (50,51,52, 53, 54)
       and r.juzhd like '140105%'
       and gs.guanxlx in (20, 30)

解决方案 »

  1.   

    distinct 只会过滤掉所有字段值一样的记录。 不知楼主指的重复数据是什么?------------------------------------------------------------------------------ 
    Blog: http://blog.csdn.net/tianlesoftware 
    网上资源: http://tianlesoftware.download.csdn.net 
    相关视频:http://blog.csdn.net/tianlesoftware/archive/2009/11/27/4886500.aspx 
    DBA1 群:62697716(满); DBA2 群:62697977