求一 SQL语句
表test,字段id1是唯一的,数据如下:
id id1
1 1
2 2
2 3
2 4
3 5
3 6
用一条语句取出id不重复的记录,应该怎么写?
------解决方案--------------------select * from test a
where not exists(select * from test where id=a.id and id1 <> a.id1)
------解决方案--------------------select id,max(id1) from test group by id
------解决方案--------------------select id,max(id1) from test group by id having count(*)=1
------解决方案--------------------id id1
表名:ta
select * from ta as a
where (select count(*) from ta where id=a.id)!> 1