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

INSERT INTO dim VALUES (1,100,100);
INSERT INTO dim VALUES (2,104,104);
INSERT INTO dim VALUES (3,108,108);

SELECT *
FROM dim;

SELECT ((w + 5) DIV 10)*10,((w + 5) DIV 10)*10,COUNT(*)
FROM dim
GROUP BY ((w + 5) DIV 10)*10,((w + 5) DIV 10)*10;

SELECT *
FROM dim
WHERE ((w + 5) DIV 10)*10=100 AND ((h + 5) DIV 10)*10=100;
