-- 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 (
    id INTEGER NOT NULL,
    navn VARCHAR2(50),
    PRIMARY KEY(id)
);

INSERT INTO T VALUES(1,'Karl');
INSERT INTO T VALUES(2,'Rasmus');
INSERT INTO T VALUES(3,'Niels');
INSERT INTO T VALUES(4,'Henrik');
INSERT INTO T VALUES(5,'Anders');
INSERT INTO T VALUES(6,'Ole');
INSERT INTO T VALUES(7,'Carsten');
INSERT INTO T VALUES(8,'Fredrik');

SELECT * FROM t;

SELECT * FROM t WHERE rownum <= 1 ORDER BY navn;

SELECT * FROM (SELECT * FROM t ORDER BY navn) WHERE rownum <= 1;

SELECT * FROM t WHERE navn >= 'D' AND rownum <= 1 ORDER BY navn;

SELECT * FROM (SELECT * FROM t WHERE navn >= 'D' ORDER BY navn) WHERE rownum <= 1;

SELECT * FROM t WHERE navn >= 'L' AND rownum <= 1 ORDER BY navn;

SELECT * FROM (SELECT * FROM t WHERE navn >= 'L' ORDER BY navn) WHERE rownum <= 1;

DROP TABLE t;
