i have duplicates like this
col1, col2
1, alex
1, alex
2, liza
2, liza
3, peter
3, peter
there are only two of each. how do i delete the duplicates?
WITH q AS
(
SELECT *,
ROW_NUMBER() OVER (PARTITION BY col1, col2 ORDER BY col1, col2) AS rn
FROM mytable
)
DELETE
FROM q
WHERE rn >= 2
See here:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With