-- Collection of code snippets by Arne Vajhøj 
-- posted to eksperten.dk, usenet and other places (2002-now) 
CREATE TABLE tal (
    id INTEGER NOT NULL,
    x DECIMAL(10,2),
    PRIMARY KEY(id)
)
GO

INSERT INTO tal VALUES(1, 3)
GO
INSERT INTO tal VALUES(2, 5)
GO
INSERT INTO tal VALUES(3, 3)
GO

SELECT AVG(CAST(x AS DECIMAL(10, 2))) AS Expr1 FROM tal
GO

SELECT CAST(AVG(x) AS DECIMAL(10, 2)) AS Expr1 FROM tal
GO

DROP TABLE tal
GO
