--建立测试环境 set nocount on createtable test(ID varchar(20),Num varchar(20),AddDate varchar(20)) insertinto test select'1','5','2008-03-10 9:26:20' insertinto test select'2','2','2008-03-10 9:26:22' insertinto test select'3','2','2008-03-10 9:28:20' insertinto test select'4','2','2008-03-15 10:26:20' insertinto test select'5','6','2008-03-15 10:26:22' go --测试 select*from test a whereexists(select1from test where id<>a.id andabs(datediff(s,a.AddDate,AddDate))<=2) --删除测试环境 droptable test set nocount off /**//* 1 5 2008-03-10 9:26:20 2 2 2008-03-10 9:26:22 4 2 2008-03-15 10:26:20 5 6 2008-03-15 10:26:22 */