select a,b,... from a,b where a.id=b.id and a.id2||''||b.id2=
(select a.id2||''||b.id2 from a,b where a.id=b.id group by a.id2,b.id2 having(count(*))>1)

解决方案 »

  1.   

    select a,b,... from a,b where a.id=b.id and a.id2||''||b.id2=
    (select max(a.id2||''||b.id2) from a,b where a.id=b.id group by a.id2,b.id2 having(count(*))>1)
      

  2.   

    bzszp(SongZip) 不行,还是样的提示
      

  3.   

    select a,b,... from a,b where a.id=b.id and a.id2||''||b.id2=
    (select a.id2||''||b.id2 from a,b where a.id=b.id group by a.id2,b.id2 having(count(*))>1
     and rownum='1')
      

  4.   

    select a,b,... from a,b where a.id=b.id and a.id2||''||b.id2=
    (select a.id2||''||b.id2 from a,b where a.id=b.id group by a.id2,b.id2 having count(*)>1
     and rownum<2)
      

  5.   

    :lwty(藏浪  提示不是GROUP BY的表达试
      

  6.   

    同意lwty(藏浪)的语句,只是他的顺序写反了:
    select a,b,... from a,b where a.id=b.id and a.id2||''||b.id2=
    (select a.id2||''||b.id2 from a,b where a.id=b.id  and rownum<2group by a.id2,b.id2 having count(*)>1
    )
      

  7.   

    从楼主写的语句看,你是想查出所有a表中ID不唯一或者b表中ID不唯一的记录。可以这样写:
    select a,b,... 
        from a, b,
             (select id from a group by id having count(*)>1
              union
              select id from b group by id having count(*)>1) c
        where a.id=b.id
          and a.id=c.id;
      

  8.   

    bobfang(匆匆过客)是二个字段合起查出重复记录
      

  9.   

    不好意思,看错了,把ID2也看成ID了。这样写
    select a,b,... 
        from a, b,
             (select a.id2||''||b.id2 ID2 from a,b
                  where a.id=b.id
                  group by a.id2,b.id2
                  having count(*)>1) c
        where a.id=b.id
          and a.id2||''||b.id2=c.id2;不过a.ID2||''||b.ID2与a.ID2||b.ID2是一样的。
      

  10.   

    而且上面的语句就等于
    select a,b,... 
        from a, b,
             (select a.id2 aid2, b.id2 bID2 from a,b
                  where a.id=b.id
                  group by a.id2,b.id2
                  having count(*)>1) c
        where a.id=b.id
          and a.id2=c.aid2 and b.id2=c.bid2;