Delete 表 where A not in (select top 1 A from 表)

解决方案 »

  1.   

    delete from tablename where a not int (select top 1 a from tablename )
      

  2.   

    delete from tablename where a not in (select top 1 a from tablename )
      

  3.   

    select top 1 * into #temp from A
    delete from A
    insert into A select * from #temp
    drop table #temp或则DELETE A
    FROM (SELECT TOP 1 * FROM A) AS t
    WHERE A.id <> t.id
      

  4.   

    create table a( A int)
    insert into a select 123
    insert into a select 324 
    insert into a select 563
    go
    delete from a
    where a not in (select top 1 a from a order by a )
    楼主真客气,没有分,没有关系,重要的是大家来论坛交流
    记住千万别倒分,刚才,看见了一个,不太高兴
      

  5.   

    我试了其中的一些帮助。谢了。但,可能是我用的不对。我的意思是:我有一个表: student
    其中一个字段是:主书目ID
    在这个字段下有好多记录。比如
    2
    2
    36
    3
    3
    89
    6
    6等。
    我是想留下
    2
    36
    3
    89
    6
    删掉重复的记录中,除第一下之外的所有的。
    保证在此字段下没有重复的。
      

  6.   

    select distinct 主书目ID from student
      

  7.   

    用一個臨時表來處理
    select identity(int,1,1) as nowid,主书目ID,其余字段1,其余字段2,其余字段3,……  into #temp1 from YourTabledelete YourTableinsert into YourTable select 主书目ID,其余字段1,其余字段2,其余字段3,……  from #temp1 where nowid in (select min(nowid) from #temp1 group by 主书目ID)drop table #temp1select * from YourTable