-- Collection of code snippets by Arne Vajhøj 
-- posted to eksperten.dk, usenet and other places (2002-now) 
CREATE TABLE ddtest (
   id INTEGER PRIMARY KEY,
   navn VARCHAR(32)
);

INSERT INTO ddtest VALUES (1, 'A');
INSERT INTO ddtest VALUES (2, 'BB');
INSERT INTO ddtest VALUES (3, 'A');
INSERT INTO ddtest VALUES (4, 'BB');
INSERT INTO ddtest VALUES (5, 'CCC');
INSERT INTO ddtest VALUES (6, 'A');

SELECT * FROM ddtest;

SELECT DISTINCT navn FROM ddtest;

SELECT id FROM ddtest ddt1 WHERE id <> (SELECT MAX(id) FROM ddtest ddt2 WHERE ddt1.navn=ddt2.navn);

