菜鸟问题,急等!!!
我想查一些数据,比如说:
A B
1 a
2 b
2 c
3 d
4 d
5 d
5 c
我想找出所有A字段中对应B字段属性不唯一的值,怎么写语句啊
[解决办法]
是不是A字段对应多个B字段的意思?
select A from [tableName] group by A having count(b) > 1
[解决办法]
同意楼上select A from [tableName] group by A having count(1) > 1
[解决办法]
楼上正解
A,B字段没有重复的吧?
[解决办法]
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)
[解决办法]
select * from t
where A in (select A from t group by A having count(1)>1)