Select * from #T a where not exists(select 1 from #T where id_key=a.id_key  and ID<a.ID)

解决方案 »

  1.   

    select * from 表
    where not exists
    (
    select aa.id from 表 as aa where aa.id = 表.id group by aa.id_key having count(*) > 1
    )
      

  2.   


    select id_key ,count(id_key ) odd from tb  group by id_key  having count(id_key )=1
      

  3.   

    select * from test where id  in (select max(id) id from test group by id_key)网上找到的比较经典的写法。
    根据id_key分组,每组取一条记录。
     就是所有不重复的记录
      

  4.   


    select * from tb where id_key in (select id_key from tb group by id_key having count(1)=1)