select a.serialno,a.srtypeid,a.servicecontent, a.contactchannel,b.HANDLINGCOMMENT
      from t_pbh_problemprocess a,t_pbh_problemworkitem b
     where a.serialno=a.serialno;
去掉 a.serialno,a.srtypeid 重复的

解决方案 »

  1.   

    重复的怎么取呢?
    select max(a.serialno),max(a.srtypeid),a.servicecontent,
    a.contactchannel,b.HANDLINGCOMMENT
    from t_pbh_problemprocess a,t_pbh_problemworkitem b
    where a.serialno=b.serialno
    group by a.servicecontent, a.contactchannel,b.HANDLINGCOMMENT;
      

  2.   


    select serialno,srtypeid,servicecontent,contactchannel,HANDLINGCOMMENT from (
    select a.serialno,a.srtypeid,a.servicecontent, a.contactchannel,b.HANDLINGCOMMENT,row_number()over(partition by a.serialno,a.srtypeid order by a.serialno,a.srtypeid) rn
      from t_pbh_problemprocess a,t_pbh_problemworkitem b
      where a.serialno=b.serialno;
    )
    where rn=1;
      

  3.   

    a.serialno,a.srtypeid 重复,但a.srtypeid不一样,这样的数据怎么取啊,取哪条啊,
    我觉得不存在去a.serialno,a.srtypeid重复的问题,直接
    select distinct a.serialno,a.srtypeid,a.servicecontent, a.contactchannel,b.HANDLINGCOMMENT
      from t_pbh_problemprocess a,t_pbh_problemworkitem b
      where a.serialno=a.serialno;
      

  4.   

    SELECT a.serialno,a.srtypeid,a.servicecontent, a.contactchannel,b.HANDLINGCOMMENT
          from t_pbh_problemprocess a,t_pbh_problemworkitem b
         WHERE a.serialno=a.serialno
         GROUP By a.serialno,a.srtypeid,a.servicecontenta.contactchannel,b.HANDLINGCOMMENT;
    我写成这样,当由于数据太大,出不来
      

  5.   


    select distinct a.serialno,a.srtypeid,a.servicecontent, a.contactchannel,b.HANDLINGCOMMENT
      from t_pbh_problemprocess a,t_pbh_problemworkitem b
      where a.serialno=a.serialno;我试了数据太大出不来
      

  6.   

    [code=SQL]
    --由于你两个字段在同一个表中,先去掉重复的,再连接:
    --另外,你t_pbh_problemprocess 表和t_pbh_problemworkitem 表的serialno字段增加索引
    select a.serialno,a.srtypeid,a.servicecontent, a.contactchannel,b.HANDLINGCOMMENT
    from t_pbh_problemworkitem b,(
                select a.* ,row_number()over(partition by a.serialno,a.srtypeid order by a.serialno,a.srtypeid) rn
                from t_pbh_problemprocess a
                where a.serialno=b.serialno) a
    )
    where a.rn=1
    and exsits(select 1 from  t_pbh_problemprocess a where a.serialno=b.serialno)
      

  7.   

    select serialno,srtypeid,servicecontent,contactchannel,HANDLINGCOMMENT from (
    select a.serialno,a.srtypeid,a.servicecontent, a.contactchannel,b.HANDLINGCOMMENT,row_number()over(partition by a.serialno,a.srtypeid order by a.serialno,a.srtypeid) rn
      from t_pbh_problemprocess a,t_pbh_problemworkitem b
      where a.serialno=b.serialno;
    )
    where rn=1;
    这条语句很快,几百万数据很快出来,我第一开始也想用的,不过不知道什么意思?
      

  8.   

    你这个sql怎么这么强大呢??paddy又没拴好,跑出来了~~杯具!!!
      

  9.   

    你看错了吧 paddy改了where a.serialno=b.serialno
    楼主是这样的where a.serialno=a.serialno
      

  10.   

    select distinct a.serialno,a.srtypeid,a.servicecontent, a.contactchannel,b.HANDLINGCOMMENT
      from t_pbh_problemprocess a,t_pbh_problemworkitem b
      where a.serialno=b.serialno;
    你再执行下这个,注意红字部分,是你把b写成a了,这个肯定快啊
      

  11.   

     select a.* ,row_number()over(partition by a.serialno,a.srtypeid order by a.serialno,a.srtypeid) rn
      from t_pbh_problemprocess a) t
    用* 会报错分类太长,说字段都要加上
      

  12.   

    试试分析函数select *
    from 
    (select a.serialno,a.srtypeid,a.servicecontent, a.contactchannel,b.HANDLINGCOMMENT,
    row_number() over(partition by a.serialno,a.srtypeid order by a.serialno,a.srtypeid) rn
      from t_pbh_problemprocess a,t_pbh_problemworkitem b
      where a.serialno=a.serialno)
    where rn=1
      

  13.   

    楼主 如果真是  where a.serialno=a.serialno;
    那你也太强了
    去重的话 分析函数不错  貌似用rowid也不错哦
      

  14.   

    我还以为是楼主贴错了,所以我给改成b.serialno了,嘿。。