select distinct max(t1.recnum) from pre_house t1 group by t1.rightcertnum
查询出617select distinct t1.recnum from pre_house t1 
查询出记录678
delete from pre_house where recnum not in(select distinct max(t1.recnum) from pre_house t1 group by t1.rightcertnum)
怎么删除0条记录呢????

解决方案 »

  1.   


    select distinct t1.recnum from pre_house t1 group by t1.rightcertnum查出是多少
      

  2.   

    试试这样
    delete from pre_house t2 where t2.recnum not in(select distinct max(t1.recnum) from pre_house t1 group by t1.rightcertnum)
      

  3.   

    既然有group为什么还要distinct?
    delete from pre_house t2 
    where t2.recnum not in (select max(t1.recnum) from pre_house t1 )
    这样不就可以了吗?