select * from table where id not in (select max(id) from table group by col1,col2,col3........)ID为表任何具有唯一性的值。

解决方案 »

  1.   

    方法二,select IDENTITY(int,1,1) as IID,* into #temp from table
    select * from #temp where id not in (select max(id) from table group by col1,col2,col3........)
      

  2.   

    假设字段1为要查询的重复字段
    select distinct 字段1 from table group by 字段1 having count(字段1)>1
      

  3.   

    select fieldname from tablename where fieldname not in (select  distinct fieldname from tablename)