当前位置: 代码迷 >> Sql Server >> 如何删除表中某个字段的值一样,但其他字段值不一样的记录
  详细解决方案

如何删除表中某个字段的值一样,但其他字段值不一样的记录

热度:58   发布时间:2016-04-27 11:56:44.0
怎么删除表中某个字段的值一样,但其他字段值不一样的记录
例如表 tbshow中


idno entdt
205073001 2009-07-07
205073001 2006-05-08
205073001 2003-08-14

想删除剩下最近一条记录 
5073001 2009-07-07
得怎么写语句 ?

------解决方案--------------------
SQL code
delete t from tbshow t where exists(select 1 from tbshow where idno=t.idno and dntdt>t.entdt)
  相关解决方案