delete test_table where testid not in(select max(testid) from test_table group by testname,testdate)
这样看行不行??

解决方案 »

  1.   

    好象不行 还有没有别的办法,难道只能这样吗
    select distinct * into #temp1  from test_table
    drop table test_table
    select * into test_table from #Temp1
    drop table #temp1
      

  2.   

    删除我不知道,不过找出来我知道,也许可以帮到你:
    比如:aa表      id,name 
                   ----------
                   01    a
                   02    b
                   01    aselect count(*) as xx ,id,name from aa group by id,name having count(*) >1
      

  3.   

    变通方法:1:先select distinct * from table_name的结果放到一个新表里
    2:删除原表
    3:新表改名
      

  4.   

    select * into #Tmp from dl_info
    select min(ID) as autoID into #Tmp2 from dl_info group by medicine_name
    select * into info_table from dl_info where ID in(select autoID from #tmp2) 
      

  5.   


    Declare @ Table
    (
    id  int identity,
    sName varchar(10)
    )Insert into @ Select '张三'
    Insert into @ Select '王二'
    Insert into @ Select '张三'
    Insert Into @ Select '李四'
    Insert into @ Select '王二'Delete from @ 
    where not id  in (select Max(id) from @ Group by sName) Select * from @
      

  6.   

    delete from test_table a where (select count(testid) from test_table where testid=a.id) > 1