id 字段A 字段B 字段C 字段D
1   001    a1    a2     a3
2   002    b2    b2     b3
3   001    a1    c2     c3
4   001    a1    d2     d3
如何字段a及字段b同时重复的挑出来?我用select * from biao group by a,b
这样分组,如何得到每组准确的数字和位置

解决方案 »

  1.   

    select * from table1 A
    where exists
    (select 1 from table1 where 字段A=A.字段A and 字段B=A.字段B and ID<A.ID )
      

  2.   

    select * from biao group by a,b
    -------------
    对你的表,上面sql是不对了
      

  3.   

    select 字段a,字段b from 表 group by 字段a,字段b  having count(*)>1
      

  4.   

    select 字段a,字段b,count(*) from 表 group by 字段a,字段b  having count(*)>1
      

  5.   

    Select * from biao as x where exists(
     select * from
    (select a,b 
     from biao group by a,b
     having count(1)>1) y where y.a=x.a and  y.b=x.b)
      

  6.   

    Select * from biao as x where exists(
     select 1 from
    (select a,b 
     from biao group by a,b
     having count(1)>1) y where y.a=x.a and  y.b=x.b)
      

  7.   

    谢谢星星门,看样子我该好好学习SQL语句了