-- 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) 
SELECT f1 FROM t1;

(SELECT * FROM (SELECT f1,f1 AS x FROM t1 UNION ALL SELECT f1,f1-100 AS x FROM t1) tmp1 WHERE x < 4 ORDER BY x DESC LIMIT 2)
UNION ALL
(SELECT * FROM (SELECT f1,f1 AS x FROM t1 UNION ALL SELECT f1,f1+100 AS x FROM t1) tmp2 WHERE x >= 4 ORDER BY x LIMIT 3)
ORDER BY x;
