我想查一些数据,比如说:
A  B
1  a
2  b
2  c
3  d
4  d
5  d
5  c
我想找出所有A字段中对应B字段属性不唯一的值,怎么写语句啊

解决方案 »

  1.   

    是不是A字段对应多个B字段的意思?select A from [tableName] group by A having count(b) > 1
      

  2.   


    同意楼上
    select A from [tableName] group by A having count(1) > 1
      

  3.   

    create table tb(A int ,  B  varchar(10))
    insert into tb select 1,  'a' 
    insert into tb select 2 , 'b' 
    insert into tb select 2 , 'c' 
    insert into tb select 3 , 'd'
    insert into tb select 4 , 'd' 
    insert into tb select 5 , 'd' 
    insert into tb select 5 , 'c' select * from tb where a in (select A from tb group by A having count(b) > 1)
      

  4.   

    select * from t
    where A in (select A from t group by A having count(1)>1)