sqlserver中刪除重複資料

木子zzgxl發表於2024-04-10
WITH CTE AS (
  SELECT License,DataTime, 
         ROW_NUMBER() OVER(PARTITION BY License,DataTime ORDER BY (SELECT 0)) AS RN
  FROM GasOff where PollutionSiteCode = 'C410526005' and DataTime >= '2024-04-10'
)
select * FROM CTE WHERE RN > 1
--delete FROM CTE WHERE RN > 1

相關文章