delete RemoteDetection WHERE REMOTEDETECTIONID IN ( select ID from ( select MIN(REMOTEDETECTIONID) ID,r.VLPN,r.PASSDATETIME from RemoteDetection r inner join ( select VLPN,PASSDATETIME,COUNT(1) as num from RemoteDetection where 1=1 group by VLPN,PASS…
删除重复的数据,在平时的工作中还是会和碰到的,感觉挺有用,从网上摘录的,记在这里,以备需要时查阅 --方法一,IN方式,适合2000/2005/2008,6728 毫秒 DELETE [student_L] WHERE id NOT IN ( SELECT MAX(id)--min(id) FROM [student_L] GROUP BY [stuid], [stuname], [Birthday], [AreaOrganID] ) /* SQL Server 分析和编译时间: CPU 时间=…
感谢孙潇楠前辈的总结,地址http://www.cnblogs.com/sunxiaonan/archive/2009/11/24/1609439.html 例如: id           name         value 1               a                 pp 2               a                 pp 3               b                 iii 4               b      …
本文转载自http://www.cnblogs.com/sunxiaonan/archive/2009/11/24/1609439.html 例如: id           name         value 1               a                 pp 2               a                 pp 3               b                 iii 4               b              …
SQL:删除重复数据,只保留一条用SQL语句,删除掉重复项只保留一条在几千条记录里,存在着些相同的记录,如何能用SQL语句,删除掉重复的呢 1.查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断 ) 2.删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录 ) ) 3.查找表中多余的重复记录(多个字段) ) 4.删除表中多余的重复记录(多个字段),只留有rowid最小的记录 ) ) 5.查找表中多余的重复记录(多个字段),不包…
例如: id           name         value 1               a                 pp 2               a                 pp 3               b                 iii 4               b                 pp 5               b                 pp 6               c           …
例如: id           name         value 1               a                 pp 2               a                 pp 3               b                 iii 4               b                 pp 5               b                 pp 6               c           …
例如: id           name         value 1               a                 pp 2               a                 pp 3               b                 iii 4               b                 pp 5               b                 pp 6               c           …
--1.建立表:Coursecreate table Course( ID int identity(1,1),--ID Student varchar(20) ,--学生 Sub varchar(20) ,--课程) --2.插入数据INSERT INTO CourseVALUES ('张三','语文'),('李四','语文' ),('王五','语文' ) INSERT INTO CourseVALUES ('张三','语文'),('李四','英语' ),('王五','数学' ) INSERT…
首先新建表: --创建示例表 CREATE TABLE t ( id ,) PRIMARY KEY, a ), b ) ) --插入数据 INSERT INTO t SELECT 'aa','bb' UNION ALL SELECT 'a1','bgb' UNION ALL SELECT 'aa','bb' UNION ALL SELECT 'a2','bb' UNION ALL SELECT 'aa3','beeb' UNION ALL SELECT 'aa','bb' UNION ALL S…