当前位置: 代码迷 >> Sql Server >> sql 数据挖掘有关问题
  详细解决方案

sql 数据挖掘有关问题

热度:88   发布时间:2016-04-27 15:37:52.0
sql 数据挖掘问题
我想把数据表中的   删除   id   相同的   日期相隔在3分钟的记录.也就是说只保留   id
相同   日期在3分钟以内的一条记录,怎么写sql语句.

------解决方案--------------------

create table ttt(id int identity,name varchar(10),createtime datetime)


delete a from ttt a
where exists(select 1 from ttt where a.name=name and datediff(mi,a.createtime,createtime) <=3 and a.createtime <createtime)
  相关解决方案