
172 PUZZLE 42 COUNTING FISH
PUZZLE
42 COUNTING FISH
Let’s go fishing! A fish and game warden is trying to find the average of
something that is not there. This is not quite as strange as it first sounds,
nor quite as simple. The warden is collecting sample data on fish in the
following table:
CREATE TABLE Samples
(sample_id INTEGER NOT NULL,
fish_name CHAR(20) NOT NULL,
found_tally INTEGER NOT NULL,
PRIMARY KEY (sample_id, fish_name));
INSERT INTO Samples
VALUES (1, 'minnow', 18),
(1, 'pike', 7),
(2, 'pike', 4),
(2, 'carp', 3),
(3, 'carp', 9),
... ;
CREATE TABLE SampleGroups
(group_id INTEGER NOT NULL,
group_descr CHAR(20) NOT NULL,
sample_id ...