.headers on
.mode column
CREATE TABLE products (
prod_id INTEGER PRIMARY KEY,
prod_name VARCHAR(50)
);
INSERT INTO products(prod_name) VALUES ('Prod 1');
INSERT INTO products(prod_name) VALUES ('Prod 2');
INSERT INTO products(prod_name) VALUES ('Prod 3');
INSERT INTO products(prod_name) VALUES ('Prod 1');
INSERT INTO products(prod_name) VALUES ('Prod 2');
INSERT INTO products(prod_name) VALUES ('Prod 3');
INSERT INTO products(prod_name) VALUES ('Prod 4');
INSERT INTO products(prod_name) VALUES ('Prod 1');
INSERT INTO products(prod_name) VALUES ('Prod 2');
INSERT INTO products(prod_name) VALUES ('Prod 3');
DELETE FROM products WHERE prod_id NOT IN(
SELECT MIN(prod_id) FROM products GROUP BY prod_name
);
SELECT * FROM products;
SQL Справочник v0.05 © 2007-2025 Igor Salnikov aka SunDoctor