We have some duplicate entries in our Items Table and trying to delete them but need one out of them
Table: Items (No Primary Key
ItemNumber,lastModifiedDate
10056,'2020-10-19'
10056,'2020-10-19'
10057,'2020-10-19'
10057,'2020-10-20'
Expected Output:
ItemNumber,lastModifiedDate
10056,'2020-10-19'
10057,'2020-10-20'
I tried below :
delete from Items where (ItemNumber,LastModifiedDate) not in
(
SELECT
ItemNumber,max(LastModifiedDate) LastModifiedDate
FROM
(select * from Items ) Items
GROUP BY
ItemNumber
);
We can do it in Mysql V8 using ROW_NUMBER() windows Function, but that feature is not available in 5.7, and i can't upgrade the DB now.
Thanks in Advance