-- 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 salg (
    id INTEGER NOT NULL PRIMARY KEY,
    dato DATE,
    styk INTEGER
);

INSERT INTO salg VALUES(1, '2009-12-01', 10);
INSERT INTO salg VALUES(2, '2009-12-02', 0);
INSERT INTO salg VALUES(3, '2009-12-03', 0);
INSERT INTO salg VALUES(4, '2009-12-04', 1);
INSERT INTO salg VALUES(5, '2009-12-05', 4);
INSERT INTO salg VALUES(6, '2009-12-01', 5);

SELECT *
FROM salg;

SELECT MAX(styk),AVG(styk),MIN(NULLIF(styk,0)),MIN(styk)
FROM salg;

DROP TABLE salg;
