How to delete duplicate records when both rows the exact same records?
create table item
(id int,
product_name varchar(20),
quantity int,
amount decimal(10,2)
);
insert into item values(1,"Laptop",10,89.9),(1,"Laptop",10,89.9),(2,"Mixer",8,82),(4,"Fridge",9,100);
This is deleting all the records for duplicate id
DELETE FROM item
WHERE ID IN (SELECT id,row_num FROM (SELECT ID, ROW_NUMBER() OVER (PARTITION BY ID ORDER BY ID) AS row_num FROM item) t
WHERE row_num > 1);