
208 PUZZLE 51 BUDGET VERSUS ACTUAL
PUZZLE
51 BUDGET VERSUS ACTUAL
C. Conrad Cady posted a simple SQL problem on the CompuServe
Gupta Forum. He has two tables, Budgeted and Actual, which describe
how a project is being done. Budgeted has a one-to-many relationship
with Actual. The tables are defined like this:
CREATE TABLE Budgeted
(task INTEGER NOT NULL PRIMARY KEY,
category INTEGER NOT NULL,
est_cost DECIMAL(8,2) NOT NULL);
CREATE TABLE Actual
(voucher DECIMAL(8,2) NOT NULL PRIMARY KEY,
task INTEGER NOT NULL REFERENCES Budgeted(task),
act_cost DECIMAL(8,2) NOT NULL);
He wants a Budgeted versus Actual comparison for each category.
This is easier to ...