clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2249070 fiddles created (32145 in the last week).

CREATE TABLE "org_units" ( "ID" INTEGER, "RESH_ID" VARCHAR(1) ); INSERT INTO "org_units" ("ID", "RESH_ID") VALUES ('1', 'a'), ('2', 'b'), ('3', 'a'), ('4', 'a'), ('5', 'b'), ('6', 'c');
6 rows affected
 hidden batch(es)


DELETE FROM "org_units" o where o."ID" in (SELECT MIN("ID") FROM "org_units" GROUP BY "RESH_ID" )
3 rows affected
 hidden batch(es)


SELECT * FROM org_units
ID RESH_ID
3 a
4 a
5 b
 hidden batch(es)


CREATE TABLE org_units2 ( "ID" INTEGER, "RESH_ID" VARCHAR(1) ); INSERT INTO org_units2 ("ID", "RESH_ID") VALUES ('1', 'a'), ('2', 'b'), ('3', 'a'), ('4', 'a'), ('5', 'b'), ('6', 'c');
6 rows affected
 hidden batch(es)


DELETE FROM "org_units2" o where o."ID" NOT in (SELECT MIN("ID") FROM "org_units2" GROUP BY "RESH_ID" )
3 rows affected
 hidden batch(es)


SELECT * FROM org_units2
ID RESH_ID
1 a
2 b
6 c
 hidden batch(es)