I have this code from this link: How can I remove duplicate rows?
;WITH cte
AS (SELECT ROW_NUMBER() OVER (PARTITION BY person_id, date_work, hours
ORDER BY ( SELECT 0)) RN
FROM work_hours)
DELETE FROM cte
WHERE RN > 1
Is it possible to remove first entered row of duplicate or i should have an extra column date_of_entry
? I want to do this if i entered same date_work and different hours PARTITION BY person_id, date_work
it remove randomly duplicates.
If it isn't possible, how can i remove duplicates with higher hours?