SELECT * FROM (
SELECT Titleid,count (TitleID) c
from [Dragonguoshi]. [dbo]. [Articleinfo]
GROUP BY Titleid,[categorycode]
Having count (TitleID) >1) as T
ORDER BY C
Delete [Dragonguoshi]. [dbo]. [Articleinfo] where ID not in (
SELECT Max (ID) c
from [Dragonguoshi]. [dbo]. [Articleinfo]
Group by TitleID, [Categorycode]
)
SQL query statement filters for duplicate datasituation One: there is a fully duplicated data in the table, that is, all field contents are the sameCREATE TABLE #
(User ID int, name varchar (10), age int)
INSERT INTO #
Select 111, ' Zhang San ', union ALL
Select 222, ' John Doe ', UNION ALL
Select 333, ' Harry ', UNION All
Select 111, ' Zhang San ', 26
Method: SELECT DISTINCT * FROM # scenario 2: There is a partial data duplication field in the table, that is, there is at least one field in the repeating data that does not repeat the CREATE TABLE #
(User ID int, name varchar (10), age int, date datetime)
INSERT INTO #
Select 111, ' Zhang San ', 2010-02-23 UNION ALL
Select 222, ' John Doe ', 2010-03-13 UNION ALL
Select 333, ' Harry ', 2011-03-25 UNION ALL
Select 111, ' Zhang San ', 26 2011-07-07 Method:--When two heavy, fetch a date large select * from T awhere not exists (select 1 from t where a. User id= user ID a. Name = Name and date >a. Date)
SQL query duplicate data, delete duplicate data, filter duplicate data