-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path50.sql
21 lines (19 loc) · 873 Bytes
/
50.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
CREATE TABLE AnthologyContributors
(isbn CHAR(10) NOT NULL,
contributor CHAR(20) NOT NULL,
category INTEGER NOT NULL,
PRIMARY KEY (isbn, contributor));
INSERT INTO AnthologyContributors VALUES(1, 'スミス', 1);
INSERT INTO AnthologyContributors VALUES(2, 'スミス', 2);
INSERT INTO AnthologyContributors VALUES(3, 'スミス', 3);
INSERT INTO AnthologyContributors VALUES(4, 'ジョン', 1);
INSERT INTO AnthologyContributors VALUES(5, 'ジョン', 2);
INSERT INTO AnthologyContributors VALUES(6, 'メアリ', 1);
INSERT INTO AnthologyContributors VALUES(7, 'メアリ', 1);
INSERT INTO AnthologyContributors VALUES(8, 'ガトー', 2);
INSERT INTO AnthologyContributors VALUES(9, 'ガトー', 3);
INSERT INTO AnthologyContributors VALUES(10,'シモン', 1);
SELECT contributor
FROM AnthologyContributors
GROUP BY contributor
HAVING COUNT(DISTINCT category) = 2;