Advance SQL: Using DELETE()

365 Days of Daily Coding: Day 142

I do not have oracle database installed in my laptop to truly work on the solution for today’s puzzle. I tried it several times for several hours however, I was not successful. Hence, the solution for today’s challenge is just done out of research. Perhaps, when I have a bit of time, I will try to find a work around.

Puzzle #27: Delete the Duplicates

https://advancedsqlpuzzles.com/advanced-sql-puzzles/

I tried the solution in the oracle environment here.

CREATE TABLE temp
( IntegerValue number(10) NOT NULL);
INSERT INTO temp (IntegerValue) VALUES (1);
INSERT INTO temp (IntegerValue) VALUES (1);
INSERT INTO temp (IntegerValue) VALUES (2);
INSERT INTO temp (IntegerValue) VALUES (3);
INSERT INTO temp (IntegerValue) VALUES (3);
INSERT INTO temp (IntegerValue) VALUES (4);

DELETE FROM temp
WHERE rowid not in
(SELECT MIN(rowid)
FROM temp
GROUP BY Integer) 

Leave a comment