-- Collection of code snippets by Arne Vajhøj 
-- (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
CREATE TABLE t (c1 INTEGER, c2 INTEGER, c3 CHAR(1), PRIMARY KEY(c1,c3))
GO
INSERT INTO t VALUES(1,    937    ,'A')
GO
INSERT INTO t VALUES(1,    365    ,'B')
GO
INSERT INTO t VALUES(1,    7499   ,'C')
GO
INSERT INTO t VALUES(1,    7527   ,'D')
GO
INSERT INTO t VALUES(2,    9121   ,'R')
GO
INSERT INTO t VALUES(2,    965    ,'S')
GO
INSERT INTO t VALUES(2,    7456   ,'T')
GO
INSERT INTO t VALUES(2,    7527   ,'U')
GO
INSERT INTO t VALUES(3,    856    ,'L')
GO
INSERT INTO t VALUES(3,    812    ,'M')
GO
INSERT INTO t VALUES(3,    7499   ,'N')
GO
SELECT t1.* FROM t t1 JOIN (SELECT c1 AS c1x,MIN(c3) AS c3x FROM t GROUP BY c1) x ON t1.c1=x.c1x AND t1.c3=x.c3x
GO
DROP TABLE t
GO
