I just want to delete duplicated rows with the same name but I want to keep these ones with higher value than other.
The problem is - when I am executing code all the duplicate rows are deleted and no one is kept. Why so?
SELECT name from ( select name, ROW_NUMBER() OVER(
PARTITION_BY(name) ORDER BY sum DESC) AS rn FROM table ) t
WHERE t.rn > 1
gives me 1400 rows but
DELETE FROM table WHERE name IN
(select company_name from ( select company_name, row_number() over (
partition by(company_name) order by sum_scoring desc) as rn from table ) t
where t.rn > 1)
deletes 2500 rows (I want to keep 1100 rows)