
PUZZLE 50 TWO OF THREE 203
PUZZLE
50 TWO OF THREE
We are putting together an anthology book with contributions from
many other books (identified by their International Standard Book
Number (ISBN)). As it works out, we want to find all authors who have
articles in exactly two out of three categories in the book for a specified
set of three categories that we put into the query as parameters.
CREATE TABLE AnthologyContributors
(isbn CHAR(10) NOT NULL,
contributor CHAR(20) NOT NULL,
category INTEGER NOT NULL,
...,
PRIMARY KEY (isbn, contributor));
Answer #1
The first thought is that this is a simple GROUP BY query that would look
like this:
SELECT isbn, ...