USE AdventureWorks2012;
GO
IF OBJECT_ID ('dbo.budgets','U') IS NOT NULL
DROP TABLE budgets;
GO
SET NOCOUNT ON;
CREATE TABLE dbo.budgets
(
dept tinyint IDENTITY,
current_year decimal NULL,
previous_year decimal NULL
);
INSERT budgets VALUES(100000, 150000);
INSERT budgets VALUES(NULL, 300000);
INSERT budgets VALUES(0, 100000);
INSERT budgets VALUES(NULL, 150000);
INSERT budgets VALUES(300000, 250000);
GO
SET NOCOUNT OFF;
SELECT AVG(NULLIF(COALESCE(current_year,
previous_year), 0.00)) AS 'Average Budget'
FROM budgets;
GO