I'm new to sql and I can't work out how to delete duplicate rows, I have a table like this called 'till_total':
till_id | total |
---|---|
1 | 80 |
1 | 80 |
1 | 60 |
2 | 30 |
2 | 30 |
2 | 50 |
I want to only delete full duplicate rows so the table ends up like this
till_id | total |
---|---|
1 | 80 |
1 | 60 |
2 | 30 |
2 | 50 |
I wrote this code to try and do it
SELECT till_id, total, COUNT(*) AS CNT
FROM till_total
GROUP BY till_id, total
HAVING COUNT(*) > 1
ORDER BY till_id;
But that seems to delete all rows where the till_id is repeated. Could anyone help me with this?