db_id
stringclasses
127 values
query
stringlengths
20
523
question
stringlengths
16
224
schema
stringclasses
127 values
party_people
SELECT T1.party_name , T2.region_name FROM party AS T1 JOIN region AS T2 ON T1.region_id = T2.region_id
Show all party names and their region names.
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT T1.party_name , T2.region_name FROM party AS T1 JOIN region AS T2 ON T1.region_id = T2.region_id
What are the names of parties and their respective regions?
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT party_name FROM party WHERE party_id NOT IN (SELECT party_id FROM Member)
Show names of parties that does not have any members.
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT party_name FROM party WHERE party_id NOT IN (SELECT party_id FROM Member)
What are the names of parties that have no members?
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT member_name FROM member WHERE party_id = 3 INTERSECT SELECT member_name FROM member WHERE party_id = 1
Show the member names which are in both the party with id 3 and the party with id 1.
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT member_name FROM member WHERE party_id = 3 INTERSECT SELECT member_name FROM member WHERE party_id = 1
Which member names are shared among members in the party with the id 3 and the party with the id 1?
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT T1.member_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id WHERE T2.Party_name != "Progress Party"
Show member names that are not in the Progress Party.
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT T1.member_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id WHERE T2.Party_name != "Progress Party"
Which member names corresponding to members who are not in the Progress Party?
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT count(*) FROM party_events
How many party events do we have?
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT count(*) FROM party_events
Count the number of party events.
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT T2.party_name , count(*) FROM party_events AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id
Show party names and the number of events for each party.
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT T2.party_name , count(*) FROM party_events AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id
How many events are there for each party?
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT member_name FROM member EXCEPT SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id = T2.member_in_charge_id
Show all member names who are not in charge of any event.
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT member_name FROM member EXCEPT SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id = T2.member_in_charge_id
What are the names of members who are not in charge of any events?
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT T2.party_name FROM party_events AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id HAVING count(*) >= 2
What are the names of parties with at least 2 events?
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT T2.party_name FROM party_events AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id HAVING count(*) >= 2
Return the names of parties that have two or more events.
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id = T2.member_in_charge_id GROUP BY T2.member_in_charge_id ORDER BY count(*) DESC LIMIT 1
What is the name of member in charge of greatest number of events?
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id = T2.member_in_charge_id GROUP BY T2.member_in_charge_id ORDER BY count(*) DESC LIMIT 1
Return the name of the member who is in charge of the most events.
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT event_name FROM party_events GROUP BY event_name HAVING count(*) > 2
find the event names that have more than 2 records.
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT event_name FROM party_events GROUP BY event_name HAVING count(*) > 2
Which event names were used more than twice for party events?
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT count(*) FROM region AS t1 JOIN party AS t2 ON t1.region_id = t2.region_id JOIN party_events AS t3 ON t2.party_id = t3.party_id WHERE t1.region_name = "United Kingdom" AND t3.Event_Name = "Annaual Meeting"
How many Annual Meeting events happened in the United Kingdom region?
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
party_people
SELECT count(*) FROM region AS t1 JOIN party AS t2 ON t1.region_id = t2.region_id JOIN party_events AS t3 ON t2.party_id = t3.party_id WHERE t1.region_name = "United Kingdom" AND t3.Event_Name = "Annaual Meeting"
Count the number of Annual Meeting events that took place in the region of the United Kingdom.
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ); CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ); CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ); CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ); INSERT INTO "region" VALUES (1,"United Kingdom","1 July 2002","Parlophone","CD","540 3622"); INSERT INTO "party" VALUES ("1","Dr. Kwame Nkrumah (MP)","1957","1958",1,"Convention Peoples Party") INSERT INTO "member" VALUES (1,"Hon Tony Abbott",3,"1994–present"); INSERT INTO "party_events" VALUES (1,"Annaual Meeting", 1,4);
pilot_record
SELECT count(*) FROM pilot
How many pilots are there?
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ); CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ); CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ); INSERT INTO "aircraft" VALUES (1,"1992","Gillig","Phantom (High Floor)","444-464 (21) INSERT INTO "pilot" VALUES (1,"Patrick O'Bryant","13",33,"United States","Center Team","2009","Bradley"); INSERT INTO "pilot_record" VALUES (1,1,1,"2003/01/04");
pilot_record
SELECT Pilot_name FROM pilot ORDER BY Rank ASC
List the names of pilots in ascending order of rank.
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ); CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ); CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ); INSERT INTO "aircraft" VALUES (1,"1992","Gillig","Phantom (High Floor)","444-464 (21) INSERT INTO "pilot" VALUES (1,"Patrick O'Bryant","13",33,"United States","Center Team","2009","Bradley"); INSERT INTO "pilot_record" VALUES (1,1,1,"2003/01/04");
pilot_record
SELECT POSITION , Team FROM pilot
What are the positions and teams of pilots?
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ); CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ); CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ); INSERT INTO "aircraft" VALUES (1,"1992","Gillig","Phantom (High Floor)","444-464 (21) INSERT INTO "pilot" VALUES (1,"Patrick O'Bryant","13",33,"United States","Center Team","2009","Bradley"); INSERT INTO "pilot_record" VALUES (1,1,1,"2003/01/04");
pilot_record
SELECT DISTINCT POSITION FROM pilot WHERE Age > 30
List the distinct positions of pilots older than 30.
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ); CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ); CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ); INSERT INTO "aircraft" VALUES (1,"1992","Gillig","Phantom (High Floor)","444-464 (21) INSERT INTO "pilot" VALUES (1,"Patrick O'Bryant","13",33,"United States","Center Team","2009","Bradley"); INSERT INTO "pilot_record" VALUES (1,1,1,"2003/01/04");
pilot_record
SELECT Pilot_name FROM pilot WHERE Team = "Bradley" OR Team = "Fordham"
Show the names of pilots from team "Bradley" or "Fordham".
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ); CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ); CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ); INSERT INTO "aircraft" VALUES (1,"1992","Gillig","Phantom (High Floor)","444-464 (21) INSERT INTO "pilot" VALUES (1,"Patrick O'Bryant","13",33,"United States","Center Team","2009","Bradley"); INSERT INTO "pilot_record" VALUES (1,1,1,"2003/01/04");
pilot_record
SELECT Join_Year FROM pilot ORDER BY Rank ASC LIMIT 1
What is the joined year of the pilot of the highest rank?
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ); CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ); CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ); INSERT INTO "aircraft" VALUES (1,"1992","Gillig","Phantom (High Floor)","444-464 (21) INSERT INTO "pilot" VALUES (1,"Patrick O'Bryant","13",33,"United States","Center Team","2009","Bradley"); INSERT INTO "pilot_record" VALUES (1,1,1,"2003/01/04");
pilot_record
SELECT Nationality , COUNT(*) FROM pilot GROUP BY Nationality
What are the different nationalities of pilots? Show each nationality and the number of pilots of each nationality.
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ); CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ); CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ); INSERT INTO "aircraft" VALUES (1,"1992","Gillig","Phantom (High Floor)","444-464 (21) INSERT INTO "pilot" VALUES (1,"Patrick O'Bryant","13",33,"United States","Center Team","2009","Bradley"); INSERT INTO "pilot_record" VALUES (1,1,1,"2003/01/04");
pilot_record
SELECT Nationality FROM pilot GROUP BY Nationality ORDER BY COUNT(*) DESC LIMIT 1
Show the most common nationality of pilots.
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ); CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ); CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ); INSERT INTO "aircraft" VALUES (1,"1992","Gillig","Phantom (High Floor)","444-464 (21) INSERT INTO "pilot" VALUES (1,"Patrick O'Bryant","13",33,"United States","Center Team","2009","Bradley"); INSERT INTO "pilot_record" VALUES (1,1,1,"2003/01/04");
pilot_record
SELECT POSITION FROM pilot WHERE Join_Year < 2000 INTERSECT SELECT POSITION FROM pilot WHERE Join_Year > 2005
Show the pilot positions that have both pilots joining after year 2005 and pilots joining before 2000.
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ); CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ); CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ); INSERT INTO "aircraft" VALUES (1,"1992","Gillig","Phantom (High Floor)","444-464 (21) INSERT INTO "pilot" VALUES (1,"Patrick O'Bryant","13",33,"United States","Center Team","2009","Bradley"); INSERT INTO "pilot_record" VALUES (1,1,1,"2003/01/04");
pilot_record
SELECT T3.Pilot_name , T2.Model FROM pilot_record AS T1 JOIN aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID JOIN pilot AS T3 ON T1.Pilot_ID = T3.Pilot_ID
Show the names of pilots and models of aircrafts they have flied with.
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ); CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ); CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ); INSERT INTO "aircraft" VALUES (1,"1992","Gillig","Phantom (High Floor)","444-464 (21) INSERT INTO "pilot" VALUES (1,"Patrick O'Bryant","13",33,"United States","Center Team","2009","Bradley"); INSERT INTO "pilot_record" VALUES (1,1,1,"2003/01/04");
pilot_record
SELECT T3.Pilot_name , T2.Fleet_Series FROM pilot_record AS T1 JOIN aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID JOIN pilot AS T3 ON T1.Pilot_ID = T3.Pilot_ID ORDER BY T3.Rank
Show the names of pilots and fleet series of the aircrafts they have flied with in ascending order of the rank of the pilot.
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ); CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ); CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ); INSERT INTO "aircraft" VALUES (1,"1992","Gillig","Phantom (High Floor)","444-464 (21) INSERT INTO "pilot" VALUES (1,"Patrick O'Bryant","13",33,"United States","Center Team","2009","Bradley"); INSERT INTO "pilot_record" VALUES (1,1,1,"2003/01/04");
pilot_record
SELECT T2.Fleet_Series FROM pilot_record AS T1 JOIN aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID JOIN pilot AS T3 ON T1.Pilot_ID = T3.Pilot_ID WHERE T3.Age < 34
Show the fleet series of the aircrafts flied by pilots younger than 34
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ); CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ); CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ); INSERT INTO "aircraft" VALUES (1,"1992","Gillig","Phantom (High Floor)","444-464 (21) INSERT INTO "pilot" VALUES (1,"Patrick O'Bryant","13",33,"United States","Center Team","2009","Bradley"); INSERT INTO "pilot_record" VALUES (1,1,1,"2003/01/04");
pilot_record
SELECT T2.Pilot_name , COUNT(*) FROM pilot_record AS T1 JOIN pilot AS T2 ON T1.pilot_ID = T2.pilot_ID GROUP BY T2.Pilot_name
Show the names of pilots and the number of records they have.
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ); CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ); CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ); INSERT INTO "aircraft" VALUES (1,"1992","Gillig","Phantom (High Floor)","444-464 (21) INSERT INTO "pilot" VALUES (1,"Patrick O'Bryant","13",33,"United States","Center Team","2009","Bradley"); INSERT INTO "pilot_record" VALUES (1,1,1,"2003/01/04");
pilot_record
SELECT T2.Pilot_name , COUNT(*) FROM pilot_record AS T1 JOIN pilot AS T2 ON T1.pilot_ID = T2.pilot_ID GROUP BY T2.Pilot_name HAVING COUNT(*) > 1
Show names of pilots that have more than one record.
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ); CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ); CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ); INSERT INTO "aircraft" VALUES (1,"1992","Gillig","Phantom (High Floor)","444-464 (21) INSERT INTO "pilot" VALUES (1,"Patrick O'Bryant","13",33,"United States","Center Team","2009","Bradley"); INSERT INTO "pilot_record" VALUES (1,1,1,"2003/01/04");
pilot_record
SELECT Pilot_name FROM pilot WHERE Pilot_ID NOT IN (SELECT Pilot_ID FROM pilot_record)
List the names of pilots that do not have any record.
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ); CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ); CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ); INSERT INTO "aircraft" VALUES (1,"1992","Gillig","Phantom (High Floor)","444-464 (21) INSERT INTO "pilot" VALUES (1,"Patrick O'Bryant","13",33,"United States","Center Team","2009","Bradley"); INSERT INTO "pilot_record" VALUES (1,1,1,"2003/01/04");
cre_Doc_Control_Systems
SELECT document_status_code FROM Ref_Document_Status;
What document status codes do we have?
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT document_status_description FROM Ref_Document_Status WHERE document_status_code = "working";
What is the description of document status code 'working'?
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT document_type_code FROM Ref_Document_Types;
What document type codes do we have?
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT document_type_description FROM Ref_Document_Types WHERE document_type_code = "Paper";
What is the description of document type 'Paper'?
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT shipping_agent_name FROM Ref_Shipping_Agents;
What are the shipping agent names?
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_name = "UPS";
What is the shipping agent code of shipping agent UPS?
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT role_code FROM ROLES;
What are all role codes?
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT role_description FROM ROLES WHERE role_code = "ED";
What is the description of role code ED?
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT count(*) FROM Employees;
How many employees do we have?
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT T1.role_description FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code WHERE T2.employee_name = "Koby";
What is the role of the employee named Koby?
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT document_id , receipt_date FROM Documents;
List all document ids and receipt dates of documents.
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT T1.role_description , T2.role_code , count(*) FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code GROUP BY T2.role_code;
How many employees does each role have? List role description, id and number of employees.
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT Roles.role_description , count(Employees.employee_id) FROM ROLES JOIN Employees ON Employees.role_code = Roles.role_code GROUP BY Employees.role_code HAVING count(Employees.employee_id) > 1;
List roles that have more than one employee. List the role description and number of employees.
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT Ref_Document_Status.document_status_description FROM Ref_Document_Status JOIN Documents ON Documents.document_status_code = Ref_Document_Status.document_status_code WHERE Documents.document_id = 1;
What is the document status description of the document with id 1?
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT count(*) FROM Documents WHERE document_status_code = "done";
How many documents have the status code done?
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT document_type_code FROM Documents WHERE document_id = 2;
List the document type code for the document with the id 2.
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper";
List the document ids for any documents with the status code done and the type code paper.
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT Ref_Shipping_Agents.shipping_agent_name FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Documents.document_id = 2;
What is the name of the shipping agent of the document with id 2?
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT count(*) FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS";
How many documents were shipped by USPS?
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT Ref_Shipping_Agents.shipping_agent_name , count(Documents.document_id) FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code GROUP BY Ref_Shipping_Agents.shipping_agent_code ORDER BY count(Documents.document_id) DESC LIMIT 1;
Which shipping agent shipped the most documents? List the shipping agent name and the number of documents.
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT receipt_date FROM Documents WHERE document_id = 3;
What is the receipt date of the document with id 3?
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT Addresses.address_details FROM Addresses JOIN Documents_Mailed ON Documents_Mailed.mailed_to_address_id = Addresses.address_id WHERE document_id = 4;
What address was the document with id 4 mailed to?
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT mailing_date FROM Documents_Mailed WHERE document_id = 7;
What is the mail date of the document with id 7?
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper" EXCEPT SELECT document_id FROM Documents JOIN Ref_Shipping_Agents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS";
List the document ids of documents with the status done and type Paper, which not shipped by the shipping agent named USPS.
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper" INTERSECT SELECT document_id FROM Documents JOIN Ref_Shipping_Agents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS";
List document id of documents status is done and document type is Paper and the document is shipped by shipping agent named USPS.
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT draft_details FROM Document_Drafts WHERE document_id = 7;
What is draft detail of the document with id 7?
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT count(*) FROM Draft_Copies WHERE document_id = 2;
How many draft copies does the document with id 2 have?
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT document_id , count(copy_number) FROM Draft_Copies GROUP BY document_id ORDER BY count(copy_number) DESC LIMIT 1;
Which document has the most draft copies? List its document id and number of draft copies.
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT document_id , count(*) FROM Draft_Copies GROUP BY document_id HAVING count(*) > 1;
Which documents have more than 1 draft copies? List document id and number of draft copies.
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id WHERE Circulation_History.document_id = 1;
List all employees in the circulation history of the document with id 1. List the employee's name.
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT employee_name FROM Employees EXCEPT SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id
List the employees who have not showed up in any circulation history of documents. List the employee's name.
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT Employees.employee_name , count(*) FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id GROUP BY Circulation_History.document_id , Circulation_History.draft_number , Circulation_History.copy_number ORDER BY count(*) DESC LIMIT 1;
Which employee has showed up in most circulation history documents. List the employee's name and the number of drafts and copies.
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
cre_Doc_Control_Systems
SELECT document_id , count(DISTINCT employee_id) FROM Circulation_History GROUP BY document_id;
For each document, list the number of employees who have showed up in the circulation history of that document. List the document ids and number of employees.
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ); CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ); CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ); CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ); CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ); CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ); CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ); CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ); CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ); CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ); CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ); INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b') INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor') INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT') INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on') INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g') INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z') INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h') INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e') INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5) INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8) INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50')
local_govt_in_alabama
SELECT T1.event_details FROM EVENTS AS T1 JOIN Services AS T2 ON T1.Service_ID = T2.Service_ID WHERE T2.Service_Type_Code = 'Marriage'
what are the event details of the services that have the type code 'Marriage'?
CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_Type_Code CHAR(15) NOT NULL, PRIMARY KEY (Service_ID) ); CREATE TABLE Participants ( Participant_ID INTEGER NOT NULL, Participant_Type_Code CHAR(15) NOT NULL, Participant_Details VARCHAR(255), PRIMARY KEY (Participant_ID) ); CREATE TABLE Events ( Event_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, Event_Details VARCHAR(255), PRIMARY KEY (Event_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID) ); CREATE TABLE Participants_in_Events ( Event_ID INTEGER NOT NULL, Participant_ID INTEGER NOT NULL, PRIMARY KEY (Event_ID, Participant_ID), FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID), FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID) ); INSERT INTO `Services` (`Service_ID`, `Service_Type_Code`) VALUES (2, 'Marriage') INSERT INTO `Participants` (`Participant_ID`, `Participant_Type_Code`, `Participant_Details`) VALUES (9, 'Organizer', 'Karlee Batz') INSERT INTO `Events` (`Event_ID`, `Service_ID`, `Event_Details`) VALUES (3, 5, 'Success') INSERT INTO `Participants_in_Events` (`Event_ID`, `Participant_ID`) VALUES (3, 26)
local_govt_in_alabama
SELECT T1.event_id , T1.event_details FROM EVENTS AS T1 JOIN Participants_in_Events AS T2 ON T1.Event_ID = T2.Event_ID GROUP BY T1.Event_ID HAVING count(*) > 1
What are the ids and details of events that have more than one participants?
CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_Type_Code CHAR(15) NOT NULL, PRIMARY KEY (Service_ID) ); CREATE TABLE Participants ( Participant_ID INTEGER NOT NULL, Participant_Type_Code CHAR(15) NOT NULL, Participant_Details VARCHAR(255), PRIMARY KEY (Participant_ID) ); CREATE TABLE Events ( Event_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, Event_Details VARCHAR(255), PRIMARY KEY (Event_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID) ); CREATE TABLE Participants_in_Events ( Event_ID INTEGER NOT NULL, Participant_ID INTEGER NOT NULL, PRIMARY KEY (Event_ID, Participant_ID), FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID), FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID) ); INSERT INTO `Services` (`Service_ID`, `Service_Type_Code`) VALUES (2, 'Marriage') INSERT INTO `Participants` (`Participant_ID`, `Participant_Type_Code`, `Participant_Details`) VALUES (9, 'Organizer', 'Karlee Batz') INSERT INTO `Events` (`Event_ID`, `Service_ID`, `Event_Details`) VALUES (3, 5, 'Success') INSERT INTO `Participants_in_Events` (`Event_ID`, `Participant_ID`) VALUES (3, 26)
local_govt_in_alabama
SELECT T1.Participant_ID , T1.Participant_Type_Code , count(*) FROM Participants AS T1 JOIN Participants_in_Events AS T2 ON T1.Participant_ID = T2.Participant_ID GROUP BY T1.Participant_ID
How many events have each participants attended? List the participant id, type and the number.
CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_Type_Code CHAR(15) NOT NULL, PRIMARY KEY (Service_ID) ); CREATE TABLE Participants ( Participant_ID INTEGER NOT NULL, Participant_Type_Code CHAR(15) NOT NULL, Participant_Details VARCHAR(255), PRIMARY KEY (Participant_ID) ); CREATE TABLE Events ( Event_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, Event_Details VARCHAR(255), PRIMARY KEY (Event_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID) ); CREATE TABLE Participants_in_Events ( Event_ID INTEGER NOT NULL, Participant_ID INTEGER NOT NULL, PRIMARY KEY (Event_ID, Participant_ID), FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID), FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID) ); INSERT INTO `Services` (`Service_ID`, `Service_Type_Code`) VALUES (2, 'Marriage') INSERT INTO `Participants` (`Participant_ID`, `Participant_Type_Code`, `Participant_Details`) VALUES (9, 'Organizer', 'Karlee Batz') INSERT INTO `Events` (`Event_ID`, `Service_ID`, `Event_Details`) VALUES (3, 5, 'Success') INSERT INTO `Participants_in_Events` (`Event_ID`, `Participant_ID`) VALUES (3, 26)
local_govt_in_alabama
SELECT Participant_ID , Participant_Type_Code , Participant_Details FROM Participants
What are all the the participant ids, type code and details?
CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_Type_Code CHAR(15) NOT NULL, PRIMARY KEY (Service_ID) ); CREATE TABLE Participants ( Participant_ID INTEGER NOT NULL, Participant_Type_Code CHAR(15) NOT NULL, Participant_Details VARCHAR(255), PRIMARY KEY (Participant_ID) ); CREATE TABLE Events ( Event_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, Event_Details VARCHAR(255), PRIMARY KEY (Event_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID) ); CREATE TABLE Participants_in_Events ( Event_ID INTEGER NOT NULL, Participant_ID INTEGER NOT NULL, PRIMARY KEY (Event_ID, Participant_ID), FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID), FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID) ); INSERT INTO `Services` (`Service_ID`, `Service_Type_Code`) VALUES (2, 'Marriage') INSERT INTO `Participants` (`Participant_ID`, `Participant_Type_Code`, `Participant_Details`) VALUES (9, 'Organizer', 'Karlee Batz') INSERT INTO `Events` (`Event_ID`, `Service_ID`, `Event_Details`) VALUES (3, 5, 'Success') INSERT INTO `Participants_in_Events` (`Event_ID`, `Participant_ID`) VALUES (3, 26)
local_govt_in_alabama
SELECT count(*) FROM participants WHERE participant_type_code = 'Organizer'
How many participants belong to the type 'Organizer'?
CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_Type_Code CHAR(15) NOT NULL, PRIMARY KEY (Service_ID) ); CREATE TABLE Participants ( Participant_ID INTEGER NOT NULL, Participant_Type_Code CHAR(15) NOT NULL, Participant_Details VARCHAR(255), PRIMARY KEY (Participant_ID) ); CREATE TABLE Events ( Event_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, Event_Details VARCHAR(255), PRIMARY KEY (Event_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID) ); CREATE TABLE Participants_in_Events ( Event_ID INTEGER NOT NULL, Participant_ID INTEGER NOT NULL, PRIMARY KEY (Event_ID, Participant_ID), FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID), FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID) ); INSERT INTO `Services` (`Service_ID`, `Service_Type_Code`) VALUES (2, 'Marriage') INSERT INTO `Participants` (`Participant_ID`, `Participant_Type_Code`, `Participant_Details`) VALUES (9, 'Organizer', 'Karlee Batz') INSERT INTO `Events` (`Event_ID`, `Service_ID`, `Event_Details`) VALUES (3, 5, 'Success') INSERT INTO `Participants_in_Events` (`Event_ID`, `Participant_ID`) VALUES (3, 26)
local_govt_in_alabama
SELECT service_type_code FROM services ORDER BY service_type_code
List the type of the services in alphabetical order.
CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_Type_Code CHAR(15) NOT NULL, PRIMARY KEY (Service_ID) ); CREATE TABLE Participants ( Participant_ID INTEGER NOT NULL, Participant_Type_Code CHAR(15) NOT NULL, Participant_Details VARCHAR(255), PRIMARY KEY (Participant_ID) ); CREATE TABLE Events ( Event_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, Event_Details VARCHAR(255), PRIMARY KEY (Event_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID) ); CREATE TABLE Participants_in_Events ( Event_ID INTEGER NOT NULL, Participant_ID INTEGER NOT NULL, PRIMARY KEY (Event_ID, Participant_ID), FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID), FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID) ); INSERT INTO `Services` (`Service_ID`, `Service_Type_Code`) VALUES (2, 'Marriage') INSERT INTO `Participants` (`Participant_ID`, `Participant_Type_Code`, `Participant_Details`) VALUES (9, 'Organizer', 'Karlee Batz') INSERT INTO `Events` (`Event_ID`, `Service_ID`, `Event_Details`) VALUES (3, 5, 'Success') INSERT INTO `Participants_in_Events` (`Event_ID`, `Participant_ID`) VALUES (3, 26)
local_govt_in_alabama
SELECT service_id , event_details FROM EVENTS
List the service id and details for the events.
CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_Type_Code CHAR(15) NOT NULL, PRIMARY KEY (Service_ID) ); CREATE TABLE Participants ( Participant_ID INTEGER NOT NULL, Participant_Type_Code CHAR(15) NOT NULL, Participant_Details VARCHAR(255), PRIMARY KEY (Participant_ID) ); CREATE TABLE Events ( Event_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, Event_Details VARCHAR(255), PRIMARY KEY (Event_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID) ); CREATE TABLE Participants_in_Events ( Event_ID INTEGER NOT NULL, Participant_ID INTEGER NOT NULL, PRIMARY KEY (Event_ID, Participant_ID), FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID), FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID) ); INSERT INTO `Services` (`Service_ID`, `Service_Type_Code`) VALUES (2, 'Marriage') INSERT INTO `Participants` (`Participant_ID`, `Participant_Type_Code`, `Participant_Details`) VALUES (9, 'Organizer', 'Karlee Batz') INSERT INTO `Events` (`Event_ID`, `Service_ID`, `Event_Details`) VALUES (3, 5, 'Success') INSERT INTO `Participants_in_Events` (`Event_ID`, `Participant_ID`) VALUES (3, 26)
local_govt_in_alabama
SELECT count(*) FROM participants AS T1 JOIN Participants_in_Events AS T2 ON T1.Participant_ID = T2.Participant_ID WHERE T1.participant_details LIKE '%Dr.%'
How many events had participants whose details had the substring 'Dr.'
CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_Type_Code CHAR(15) NOT NULL, PRIMARY KEY (Service_ID) ); CREATE TABLE Participants ( Participant_ID INTEGER NOT NULL, Participant_Type_Code CHAR(15) NOT NULL, Participant_Details VARCHAR(255), PRIMARY KEY (Participant_ID) ); CREATE TABLE Events ( Event_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, Event_Details VARCHAR(255), PRIMARY KEY (Event_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID) ); CREATE TABLE Participants_in_Events ( Event_ID INTEGER NOT NULL, Participant_ID INTEGER NOT NULL, PRIMARY KEY (Event_ID, Participant_ID), FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID), FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID) ); INSERT INTO `Services` (`Service_ID`, `Service_Type_Code`) VALUES (2, 'Marriage') INSERT INTO `Participants` (`Participant_ID`, `Participant_Type_Code`, `Participant_Details`) VALUES (9, 'Organizer', 'Karlee Batz') INSERT INTO `Events` (`Event_ID`, `Service_ID`, `Event_Details`) VALUES (3, 5, 'Success') INSERT INTO `Participants_in_Events` (`Event_ID`, `Participant_ID`) VALUES (3, 26)
local_govt_in_alabama
SELECT participant_type_code FROM participants GROUP BY participant_type_code ORDER BY count(*) DESC LIMIT 1
What is the most common participant type?
CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_Type_Code CHAR(15) NOT NULL, PRIMARY KEY (Service_ID) ); CREATE TABLE Participants ( Participant_ID INTEGER NOT NULL, Participant_Type_Code CHAR(15) NOT NULL, Participant_Details VARCHAR(255), PRIMARY KEY (Participant_ID) ); CREATE TABLE Events ( Event_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, Event_Details VARCHAR(255), PRIMARY KEY (Event_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID) ); CREATE TABLE Participants_in_Events ( Event_ID INTEGER NOT NULL, Participant_ID INTEGER NOT NULL, PRIMARY KEY (Event_ID, Participant_ID), FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID), FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID) ); INSERT INTO `Services` (`Service_ID`, `Service_Type_Code`) VALUES (2, 'Marriage') INSERT INTO `Participants` (`Participant_ID`, `Participant_Type_Code`, `Participant_Details`) VALUES (9, 'Organizer', 'Karlee Batz') INSERT INTO `Events` (`Event_ID`, `Service_ID`, `Event_Details`) VALUES (3, 5, 'Success') INSERT INTO `Participants_in_Events` (`Event_ID`, `Participant_ID`) VALUES (3, 26)
local_govt_in_alabama
SELECT T3.service_id , T4.Service_Type_Code FROM participants AS T1 JOIN Participants_in_Events AS T2 ON T1.Participant_ID = T2.Participant_ID JOIN EVENTS AS T3 ON T2.Event_ID = T3.Event_ID JOIN services AS T4 ON T3.service_id = T4.service_id GROUP BY T3.service_id ORDER BY count(*) ASC LIMIT 1
Which service id and type has the least number of participants?
CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_Type_Code CHAR(15) NOT NULL, PRIMARY KEY (Service_ID) ); CREATE TABLE Participants ( Participant_ID INTEGER NOT NULL, Participant_Type_Code CHAR(15) NOT NULL, Participant_Details VARCHAR(255), PRIMARY KEY (Participant_ID) ); CREATE TABLE Events ( Event_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, Event_Details VARCHAR(255), PRIMARY KEY (Event_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID) ); CREATE TABLE Participants_in_Events ( Event_ID INTEGER NOT NULL, Participant_ID INTEGER NOT NULL, PRIMARY KEY (Event_ID, Participant_ID), FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID), FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID) ); INSERT INTO `Services` (`Service_ID`, `Service_Type_Code`) VALUES (2, 'Marriage') INSERT INTO `Participants` (`Participant_ID`, `Participant_Type_Code`, `Participant_Details`) VALUES (9, 'Organizer', 'Karlee Batz') INSERT INTO `Events` (`Event_ID`, `Service_ID`, `Event_Details`) VALUES (3, 5, 'Success') INSERT INTO `Participants_in_Events` (`Event_ID`, `Participant_ID`) VALUES (3, 26)
local_govt_in_alabama
SELECT Event_ID FROM Participants_in_Events GROUP BY Event_ID ORDER BY count(*) DESC LIMIT 1
What is the id of the event with the most participants?
CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_Type_Code CHAR(15) NOT NULL, PRIMARY KEY (Service_ID) ); CREATE TABLE Participants ( Participant_ID INTEGER NOT NULL, Participant_Type_Code CHAR(15) NOT NULL, Participant_Details VARCHAR(255), PRIMARY KEY (Participant_ID) ); CREATE TABLE Events ( Event_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, Event_Details VARCHAR(255), PRIMARY KEY (Event_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID) ); CREATE TABLE Participants_in_Events ( Event_ID INTEGER NOT NULL, Participant_ID INTEGER NOT NULL, PRIMARY KEY (Event_ID, Participant_ID), FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID), FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID) ); INSERT INTO `Services` (`Service_ID`, `Service_Type_Code`) VALUES (2, 'Marriage') INSERT INTO `Participants` (`Participant_ID`, `Participant_Type_Code`, `Participant_Details`) VALUES (9, 'Organizer', 'Karlee Batz') INSERT INTO `Events` (`Event_ID`, `Service_ID`, `Event_Details`) VALUES (3, 5, 'Success') INSERT INTO `Participants_in_Events` (`Event_ID`, `Participant_ID`) VALUES (3, 26)
local_govt_in_alabama
SELECT event_id FROM EVENTS EXCEPT SELECT T1.event_id FROM Participants_in_Events AS T1 JOIN Participants AS T2 ON T1.Participant_ID = T2.Participant_ID WHERE Participant_Details = 'Kenyatta Kuhn'
Which events id does not have any participant with detail 'Kenyatta Kuhn'?
CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_Type_Code CHAR(15) NOT NULL, PRIMARY KEY (Service_ID) ); CREATE TABLE Participants ( Participant_ID INTEGER NOT NULL, Participant_Type_Code CHAR(15) NOT NULL, Participant_Details VARCHAR(255), PRIMARY KEY (Participant_ID) ); CREATE TABLE Events ( Event_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, Event_Details VARCHAR(255), PRIMARY KEY (Event_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID) ); CREATE TABLE Participants_in_Events ( Event_ID INTEGER NOT NULL, Participant_ID INTEGER NOT NULL, PRIMARY KEY (Event_ID, Participant_ID), FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID), FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID) ); INSERT INTO `Services` (`Service_ID`, `Service_Type_Code`) VALUES (2, 'Marriage') INSERT INTO `Participants` (`Participant_ID`, `Participant_Type_Code`, `Participant_Details`) VALUES (9, 'Organizer', 'Karlee Batz') INSERT INTO `Events` (`Event_ID`, `Service_ID`, `Event_Details`) VALUES (3, 5, 'Success') INSERT INTO `Participants_in_Events` (`Event_ID`, `Participant_ID`) VALUES (3, 26)
local_govt_in_alabama
SELECT T1.service_type_code FROM services AS T1 JOIN EVENTS AS T2 ON T1.service_id = T2.service_id WHERE T2.event_details = 'Success' INTERSECT SELECT T1.service_type_code FROM services AS T1 JOIN EVENTS AS T2 ON T1.service_id = T2.service_id WHERE T2.event_details = 'Fail'
Which services type had both successful and failure event details?
CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_Type_Code CHAR(15) NOT NULL, PRIMARY KEY (Service_ID) ); CREATE TABLE Participants ( Participant_ID INTEGER NOT NULL, Participant_Type_Code CHAR(15) NOT NULL, Participant_Details VARCHAR(255), PRIMARY KEY (Participant_ID) ); CREATE TABLE Events ( Event_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, Event_Details VARCHAR(255), PRIMARY KEY (Event_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID) ); CREATE TABLE Participants_in_Events ( Event_ID INTEGER NOT NULL, Participant_ID INTEGER NOT NULL, PRIMARY KEY (Event_ID, Participant_ID), FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID), FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID) ); INSERT INTO `Services` (`Service_ID`, `Service_Type_Code`) VALUES (2, 'Marriage') INSERT INTO `Participants` (`Participant_ID`, `Participant_Type_Code`, `Participant_Details`) VALUES (9, 'Organizer', 'Karlee Batz') INSERT INTO `Events` (`Event_ID`, `Service_ID`, `Event_Details`) VALUES (3, 5, 'Success') INSERT INTO `Participants_in_Events` (`Event_ID`, `Participant_ID`) VALUES (3, 26)
local_govt_in_alabama
SELECT count(*) FROM EVENTS WHERE event_id NOT IN (SELECT event_id FROM Participants_in_Events)
How many events did not have any participants?
CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_Type_Code CHAR(15) NOT NULL, PRIMARY KEY (Service_ID) ); CREATE TABLE Participants ( Participant_ID INTEGER NOT NULL, Participant_Type_Code CHAR(15) NOT NULL, Participant_Details VARCHAR(255), PRIMARY KEY (Participant_ID) ); CREATE TABLE Events ( Event_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, Event_Details VARCHAR(255), PRIMARY KEY (Event_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID) ); CREATE TABLE Participants_in_Events ( Event_ID INTEGER NOT NULL, Participant_ID INTEGER NOT NULL, PRIMARY KEY (Event_ID, Participant_ID), FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID), FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID) ); INSERT INTO `Services` (`Service_ID`, `Service_Type_Code`) VALUES (2, 'Marriage') INSERT INTO `Participants` (`Participant_ID`, `Participant_Type_Code`, `Participant_Details`) VALUES (9, 'Organizer', 'Karlee Batz') INSERT INTO `Events` (`Event_ID`, `Service_ID`, `Event_Details`) VALUES (3, 5, 'Success') INSERT INTO `Participants_in_Events` (`Event_ID`, `Participant_ID`) VALUES (3, 26)
local_govt_in_alabama
SELECT count(DISTINCT participant_id) FROM participants_in_Events
What are all the distinct participant ids who attended any events?
CREATE TABLE Services ( Service_ID INTEGER NOT NULL, Service_Type_Code CHAR(15) NOT NULL, PRIMARY KEY (Service_ID) ); CREATE TABLE Participants ( Participant_ID INTEGER NOT NULL, Participant_Type_Code CHAR(15) NOT NULL, Participant_Details VARCHAR(255), PRIMARY KEY (Participant_ID) ); CREATE TABLE Events ( Event_ID INTEGER NOT NULL, Service_ID INTEGER NOT NULL, Event_Details VARCHAR(255), PRIMARY KEY (Event_ID), FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID) ); CREATE TABLE Participants_in_Events ( Event_ID INTEGER NOT NULL, Participant_ID INTEGER NOT NULL, PRIMARY KEY (Event_ID, Participant_ID), FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID), FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID) ); INSERT INTO `Services` (`Service_ID`, `Service_Type_Code`) VALUES (2, 'Marriage') INSERT INTO `Participants` (`Participant_ID`, `Participant_Type_Code`, `Participant_Details`) VALUES (9, 'Organizer', 'Karlee Batz') INSERT INTO `Events` (`Event_ID`, `Service_ID`, `Event_Details`) VALUES (3, 5, 'Success') INSERT INTO `Participants_in_Events` (`Event_ID`, `Participant_ID`) VALUES (3, 26)
machine_repair
SELECT count(*) FROM technician
How many technicians are there?
CREATE TABLE "repair" ( "repair_ID" int, "name" text, "Launch_Date" text, "Notes" text, PRIMARY KEY ("repair_ID") ); CREATE TABLE "machine" ( "Machine_ID" int, "Making_Year" int, "Class" text, "Team" text, "Machine_series" text, "value_points" real, "quality_rank" int, PRIMARY KEY ("Machine_ID") ); CREATE TABLE "technician" ( "technician_id" real, "Name" text, "Team" text, "Starting_Year" real, "Age" int, PRIMARY Key ("technician_id") ); CREATE TABLE "repair_assignment" ( "technician_id" int, "repair_ID" int, "Machine_ID" int, PRIMARY Key ("technician_id","repair_ID","Machine_ID"), FOREIGN KEY (`technician_id`) REFERENCES `technician`(`technician_id`), FOREIGN KEY (`repair_ID`) REFERENCES `repair`(`repair_ID`), FOREIGN KEY (`Machine_ID`) REFERENCES `machine`(`Machine_ID`) ); INSERT INTO "repair" VALUES (1,"Discoverer","21 Jan 2009","repair Failed. Failed to achieve orbit"); INSERT INTO "machine" VALUES (1,"1991","125cc","Hero Sports TS- Honda","RS125","105",2); INSERT INTO "technician" VALUES ("1","Joe Sewell","NYY","2012",37); INSERT INTO "repair_assignment" VALUES (1,1,1);
machine_repair
SELECT count(*) FROM technician
What is the number of technicians?
CREATE TABLE "repair" ( "repair_ID" int, "name" text, "Launch_Date" text, "Notes" text, PRIMARY KEY ("repair_ID") ); CREATE TABLE "machine" ( "Machine_ID" int, "Making_Year" int, "Class" text, "Team" text, "Machine_series" text, "value_points" real, "quality_rank" int, PRIMARY KEY ("Machine_ID") ); CREATE TABLE "technician" ( "technician_id" real, "Name" text, "Team" text, "Starting_Year" real, "Age" int, PRIMARY Key ("technician_id") ); CREATE TABLE "repair_assignment" ( "technician_id" int, "repair_ID" int, "Machine_ID" int, PRIMARY Key ("technician_id","repair_ID","Machine_ID"), FOREIGN KEY (`technician_id`) REFERENCES `technician`(`technician_id`), FOREIGN KEY (`repair_ID`) REFERENCES `repair`(`repair_ID`), FOREIGN KEY (`Machine_ID`) REFERENCES `machine`(`Machine_ID`) ); INSERT INTO "repair" VALUES (1,"Discoverer","21 Jan 2009","repair Failed. Failed to achieve orbit"); INSERT INTO "machine" VALUES (1,"1991","125cc","Hero Sports TS- Honda","RS125","105",2); INSERT INTO "technician" VALUES ("1","Joe Sewell","NYY","2012",37); INSERT INTO "repair_assignment" VALUES (1,1,1);
machine_repair
SELECT Name FROM technician ORDER BY Age ASC
List the names of technicians in ascending order of age.
CREATE TABLE "repair" ( "repair_ID" int, "name" text, "Launch_Date" text, "Notes" text, PRIMARY KEY ("repair_ID") ); CREATE TABLE "machine" ( "Machine_ID" int, "Making_Year" int, "Class" text, "Team" text, "Machine_series" text, "value_points" real, "quality_rank" int, PRIMARY KEY ("Machine_ID") ); CREATE TABLE "technician" ( "technician_id" real, "Name" text, "Team" text, "Starting_Year" real, "Age" int, PRIMARY Key ("technician_id") ); CREATE TABLE "repair_assignment" ( "technician_id" int, "repair_ID" int, "Machine_ID" int, PRIMARY Key ("technician_id","repair_ID","Machine_ID"), FOREIGN KEY (`technician_id`) REFERENCES `technician`(`technician_id`), FOREIGN KEY (`repair_ID`) REFERENCES `repair`(`repair_ID`), FOREIGN KEY (`Machine_ID`) REFERENCES `machine`(`Machine_ID`) ); INSERT INTO "repair" VALUES (1,"Discoverer","21 Jan 2009","repair Failed. Failed to achieve orbit"); INSERT INTO "machine" VALUES (1,"1991","125cc","Hero Sports TS- Honda","RS125","105",2); INSERT INTO "technician" VALUES ("1","Joe Sewell","NYY","2012",37); INSERT INTO "repair_assignment" VALUES (1,1,1);
machine_repair
SELECT Name FROM technician ORDER BY Age ASC
What are the names of the technicians by ascending order of age?
CREATE TABLE "repair" ( "repair_ID" int, "name" text, "Launch_Date" text, "Notes" text, PRIMARY KEY ("repair_ID") ); CREATE TABLE "machine" ( "Machine_ID" int, "Making_Year" int, "Class" text, "Team" text, "Machine_series" text, "value_points" real, "quality_rank" int, PRIMARY KEY ("Machine_ID") ); CREATE TABLE "technician" ( "technician_id" real, "Name" text, "Team" text, "Starting_Year" real, "Age" int, PRIMARY Key ("technician_id") ); CREATE TABLE "repair_assignment" ( "technician_id" int, "repair_ID" int, "Machine_ID" int, PRIMARY Key ("technician_id","repair_ID","Machine_ID"), FOREIGN KEY (`technician_id`) REFERENCES `technician`(`technician_id`), FOREIGN KEY (`repair_ID`) REFERENCES `repair`(`repair_ID`), FOREIGN KEY (`Machine_ID`) REFERENCES `machine`(`Machine_ID`) ); INSERT INTO "repair" VALUES (1,"Discoverer","21 Jan 2009","repair Failed. Failed to achieve orbit"); INSERT INTO "machine" VALUES (1,"1991","125cc","Hero Sports TS- Honda","RS125","105",2); INSERT INTO "technician" VALUES ("1","Joe Sewell","NYY","2012",37); INSERT INTO "repair_assignment" VALUES (1,1,1);
machine_repair
SELECT Team , Starting_Year FROM technician
What are the team and starting year of technicians?
CREATE TABLE "repair" ( "repair_ID" int, "name" text, "Launch_Date" text, "Notes" text, PRIMARY KEY ("repair_ID") ); CREATE TABLE "machine" ( "Machine_ID" int, "Making_Year" int, "Class" text, "Team" text, "Machine_series" text, "value_points" real, "quality_rank" int, PRIMARY KEY ("Machine_ID") ); CREATE TABLE "technician" ( "technician_id" real, "Name" text, "Team" text, "Starting_Year" real, "Age" int, PRIMARY Key ("technician_id") ); CREATE TABLE "repair_assignment" ( "technician_id" int, "repair_ID" int, "Machine_ID" int, PRIMARY Key ("technician_id","repair_ID","Machine_ID"), FOREIGN KEY (`technician_id`) REFERENCES `technician`(`technician_id`), FOREIGN KEY (`repair_ID`) REFERENCES `repair`(`repair_ID`), FOREIGN KEY (`Machine_ID`) REFERENCES `machine`(`Machine_ID`) ); INSERT INTO "repair" VALUES (1,"Discoverer","21 Jan 2009","repair Failed. Failed to achieve orbit"); INSERT INTO "machine" VALUES (1,"1991","125cc","Hero Sports TS- Honda","RS125","105",2); INSERT INTO "technician" VALUES ("1","Joe Sewell","NYY","2012",37); INSERT INTO "repair_assignment" VALUES (1,1,1);
machine_repair
SELECT Team , Starting_Year FROM technician
What is the team and starting year for each technician?
CREATE TABLE "repair" ( "repair_ID" int, "name" text, "Launch_Date" text, "Notes" text, PRIMARY KEY ("repair_ID") ); CREATE TABLE "machine" ( "Machine_ID" int, "Making_Year" int, "Class" text, "Team" text, "Machine_series" text, "value_points" real, "quality_rank" int, PRIMARY KEY ("Machine_ID") ); CREATE TABLE "technician" ( "technician_id" real, "Name" text, "Team" text, "Starting_Year" real, "Age" int, PRIMARY Key ("technician_id") ); CREATE TABLE "repair_assignment" ( "technician_id" int, "repair_ID" int, "Machine_ID" int, PRIMARY Key ("technician_id","repair_ID","Machine_ID"), FOREIGN KEY (`technician_id`) REFERENCES `technician`(`technician_id`), FOREIGN KEY (`repair_ID`) REFERENCES `repair`(`repair_ID`), FOREIGN KEY (`Machine_ID`) REFERENCES `machine`(`Machine_ID`) ); INSERT INTO "repair" VALUES (1,"Discoverer","21 Jan 2009","repair Failed. Failed to achieve orbit"); INSERT INTO "machine" VALUES (1,"1991","125cc","Hero Sports TS- Honda","RS125","105",2); INSERT INTO "technician" VALUES ("1","Joe Sewell","NYY","2012",37); INSERT INTO "repair_assignment" VALUES (1,1,1);
machine_repair
SELECT Name FROM technician WHERE Team != "NYY"
List the name of technicians whose team is not "NYY".
CREATE TABLE "repair" ( "repair_ID" int, "name" text, "Launch_Date" text, "Notes" text, PRIMARY KEY ("repair_ID") ); CREATE TABLE "machine" ( "Machine_ID" int, "Making_Year" int, "Class" text, "Team" text, "Machine_series" text, "value_points" real, "quality_rank" int, PRIMARY KEY ("Machine_ID") ); CREATE TABLE "technician" ( "technician_id" real, "Name" text, "Team" text, "Starting_Year" real, "Age" int, PRIMARY Key ("technician_id") ); CREATE TABLE "repair_assignment" ( "technician_id" int, "repair_ID" int, "Machine_ID" int, PRIMARY Key ("technician_id","repair_ID","Machine_ID"), FOREIGN KEY (`technician_id`) REFERENCES `technician`(`technician_id`), FOREIGN KEY (`repair_ID`) REFERENCES `repair`(`repair_ID`), FOREIGN KEY (`Machine_ID`) REFERENCES `machine`(`Machine_ID`) ); INSERT INTO "repair" VALUES (1,"Discoverer","21 Jan 2009","repair Failed. Failed to achieve orbit"); INSERT INTO "machine" VALUES (1,"1991","125cc","Hero Sports TS- Honda","RS125","105",2); INSERT INTO "technician" VALUES ("1","Joe Sewell","NYY","2012",37); INSERT INTO "repair_assignment" VALUES (1,1,1);
machine_repair
SELECT Name FROM technician WHERE Team != "NYY"
What is the name of the technician whose team is not 'NYY'?
CREATE TABLE "repair" ( "repair_ID" int, "name" text, "Launch_Date" text, "Notes" text, PRIMARY KEY ("repair_ID") ); CREATE TABLE "machine" ( "Machine_ID" int, "Making_Year" int, "Class" text, "Team" text, "Machine_series" text, "value_points" real, "quality_rank" int, PRIMARY KEY ("Machine_ID") ); CREATE TABLE "technician" ( "technician_id" real, "Name" text, "Team" text, "Starting_Year" real, "Age" int, PRIMARY Key ("technician_id") ); CREATE TABLE "repair_assignment" ( "technician_id" int, "repair_ID" int, "Machine_ID" int, PRIMARY Key ("technician_id","repair_ID","Machine_ID"), FOREIGN KEY (`technician_id`) REFERENCES `technician`(`technician_id`), FOREIGN KEY (`repair_ID`) REFERENCES `repair`(`repair_ID`), FOREIGN KEY (`Machine_ID`) REFERENCES `machine`(`Machine_ID`) ); INSERT INTO "repair" VALUES (1,"Discoverer","21 Jan 2009","repair Failed. Failed to achieve orbit"); INSERT INTO "machine" VALUES (1,"1991","125cc","Hero Sports TS- Honda","RS125","105",2); INSERT INTO "technician" VALUES ("1","Joe Sewell","NYY","2012",37); INSERT INTO "repair_assignment" VALUES (1,1,1);
machine_repair
SELECT Name FROM technician WHERE Age = 36 OR Age = 37
Show the name of technicians aged either 36 or 37
CREATE TABLE "repair" ( "repair_ID" int, "name" text, "Launch_Date" text, "Notes" text, PRIMARY KEY ("repair_ID") ); CREATE TABLE "machine" ( "Machine_ID" int, "Making_Year" int, "Class" text, "Team" text, "Machine_series" text, "value_points" real, "quality_rank" int, PRIMARY KEY ("Machine_ID") ); CREATE TABLE "technician" ( "technician_id" real, "Name" text, "Team" text, "Starting_Year" real, "Age" int, PRIMARY Key ("technician_id") ); CREATE TABLE "repair_assignment" ( "technician_id" int, "repair_ID" int, "Machine_ID" int, PRIMARY Key ("technician_id","repair_ID","Machine_ID"), FOREIGN KEY (`technician_id`) REFERENCES `technician`(`technician_id`), FOREIGN KEY (`repair_ID`) REFERENCES `repair`(`repair_ID`), FOREIGN KEY (`Machine_ID`) REFERENCES `machine`(`Machine_ID`) ); INSERT INTO "repair" VALUES (1,"Discoverer","21 Jan 2009","repair Failed. Failed to achieve orbit"); INSERT INTO "machine" VALUES (1,"1991","125cc","Hero Sports TS- Honda","RS125","105",2); INSERT INTO "technician" VALUES ("1","Joe Sewell","NYY","2012",37); INSERT INTO "repair_assignment" VALUES (1,1,1);
machine_repair
SELECT Name FROM technician WHERE Age = 36 OR Age = 37
What are the names of the technicians aged either 36 or 37?
CREATE TABLE "repair" ( "repair_ID" int, "name" text, "Launch_Date" text, "Notes" text, PRIMARY KEY ("repair_ID") ); CREATE TABLE "machine" ( "Machine_ID" int, "Making_Year" int, "Class" text, "Team" text, "Machine_series" text, "value_points" real, "quality_rank" int, PRIMARY KEY ("Machine_ID") ); CREATE TABLE "technician" ( "technician_id" real, "Name" text, "Team" text, "Starting_Year" real, "Age" int, PRIMARY Key ("technician_id") ); CREATE TABLE "repair_assignment" ( "technician_id" int, "repair_ID" int, "Machine_ID" int, PRIMARY Key ("technician_id","repair_ID","Machine_ID"), FOREIGN KEY (`technician_id`) REFERENCES `technician`(`technician_id`), FOREIGN KEY (`repair_ID`) REFERENCES `repair`(`repair_ID`), FOREIGN KEY (`Machine_ID`) REFERENCES `machine`(`Machine_ID`) ); INSERT INTO "repair" VALUES (1,"Discoverer","21 Jan 2009","repair Failed. Failed to achieve orbit"); INSERT INTO "machine" VALUES (1,"1991","125cc","Hero Sports TS- Honda","RS125","105",2); INSERT INTO "technician" VALUES ("1","Joe Sewell","NYY","2012",37); INSERT INTO "repair_assignment" VALUES (1,1,1);
machine_repair
SELECT Starting_Year FROM technician ORDER BY Age DESC LIMIT 1
What is the starting year of the oldest technicians?
CREATE TABLE "repair" ( "repair_ID" int, "name" text, "Launch_Date" text, "Notes" text, PRIMARY KEY ("repair_ID") ); CREATE TABLE "machine" ( "Machine_ID" int, "Making_Year" int, "Class" text, "Team" text, "Machine_series" text, "value_points" real, "quality_rank" int, PRIMARY KEY ("Machine_ID") ); CREATE TABLE "technician" ( "technician_id" real, "Name" text, "Team" text, "Starting_Year" real, "Age" int, PRIMARY Key ("technician_id") ); CREATE TABLE "repair_assignment" ( "technician_id" int, "repair_ID" int, "Machine_ID" int, PRIMARY Key ("technician_id","repair_ID","Machine_ID"), FOREIGN KEY (`technician_id`) REFERENCES `technician`(`technician_id`), FOREIGN KEY (`repair_ID`) REFERENCES `repair`(`repair_ID`), FOREIGN KEY (`Machine_ID`) REFERENCES `machine`(`Machine_ID`) ); INSERT INTO "repair" VALUES (1,"Discoverer","21 Jan 2009","repair Failed. Failed to achieve orbit"); INSERT INTO "machine" VALUES (1,"1991","125cc","Hero Sports TS- Honda","RS125","105",2); INSERT INTO "technician" VALUES ("1","Joe Sewell","NYY","2012",37); INSERT INTO "repair_assignment" VALUES (1,1,1);
machine_repair
SELECT Starting_Year FROM technician ORDER BY Age DESC LIMIT 1
What is the starting year for the oldest technician?
CREATE TABLE "repair" ( "repair_ID" int, "name" text, "Launch_Date" text, "Notes" text, PRIMARY KEY ("repair_ID") ); CREATE TABLE "machine" ( "Machine_ID" int, "Making_Year" int, "Class" text, "Team" text, "Machine_series" text, "value_points" real, "quality_rank" int, PRIMARY KEY ("Machine_ID") ); CREATE TABLE "technician" ( "technician_id" real, "Name" text, "Team" text, "Starting_Year" real, "Age" int, PRIMARY Key ("technician_id") ); CREATE TABLE "repair_assignment" ( "technician_id" int, "repair_ID" int, "Machine_ID" int, PRIMARY Key ("technician_id","repair_ID","Machine_ID"), FOREIGN KEY (`technician_id`) REFERENCES `technician`(`technician_id`), FOREIGN KEY (`repair_ID`) REFERENCES `repair`(`repair_ID`), FOREIGN KEY (`Machine_ID`) REFERENCES `machine`(`Machine_ID`) ); INSERT INTO "repair" VALUES (1,"Discoverer","21 Jan 2009","repair Failed. Failed to achieve orbit"); INSERT INTO "machine" VALUES (1,"1991","125cc","Hero Sports TS- Honda","RS125","105",2); INSERT INTO "technician" VALUES ("1","Joe Sewell","NYY","2012",37); INSERT INTO "repair_assignment" VALUES (1,1,1);
machine_repair
SELECT Team , COUNT(*) FROM technician GROUP BY Team
Show different teams of technicians and the number of technicians in each team.
CREATE TABLE "repair" ( "repair_ID" int, "name" text, "Launch_Date" text, "Notes" text, PRIMARY KEY ("repair_ID") ); CREATE TABLE "machine" ( "Machine_ID" int, "Making_Year" int, "Class" text, "Team" text, "Machine_series" text, "value_points" real, "quality_rank" int, PRIMARY KEY ("Machine_ID") ); CREATE TABLE "technician" ( "technician_id" real, "Name" text, "Team" text, "Starting_Year" real, "Age" int, PRIMARY Key ("technician_id") ); CREATE TABLE "repair_assignment" ( "technician_id" int, "repair_ID" int, "Machine_ID" int, PRIMARY Key ("technician_id","repair_ID","Machine_ID"), FOREIGN KEY (`technician_id`) REFERENCES `technician`(`technician_id`), FOREIGN KEY (`repair_ID`) REFERENCES `repair`(`repair_ID`), FOREIGN KEY (`Machine_ID`) REFERENCES `machine`(`Machine_ID`) ); INSERT INTO "repair" VALUES (1,"Discoverer","21 Jan 2009","repair Failed. Failed to achieve orbit"); INSERT INTO "machine" VALUES (1,"1991","125cc","Hero Sports TS- Honda","RS125","105",2); INSERT INTO "technician" VALUES ("1","Joe Sewell","NYY","2012",37); INSERT INTO "repair_assignment" VALUES (1,1,1);
machine_repair
SELECT Team , COUNT(*) FROM technician GROUP BY Team
For each team, how many technicians are there?
CREATE TABLE "repair" ( "repair_ID" int, "name" text, "Launch_Date" text, "Notes" text, PRIMARY KEY ("repair_ID") ); CREATE TABLE "machine" ( "Machine_ID" int, "Making_Year" int, "Class" text, "Team" text, "Machine_series" text, "value_points" real, "quality_rank" int, PRIMARY KEY ("Machine_ID") ); CREATE TABLE "technician" ( "technician_id" real, "Name" text, "Team" text, "Starting_Year" real, "Age" int, PRIMARY Key ("technician_id") ); CREATE TABLE "repair_assignment" ( "technician_id" int, "repair_ID" int, "Machine_ID" int, PRIMARY Key ("technician_id","repair_ID","Machine_ID"), FOREIGN KEY (`technician_id`) REFERENCES `technician`(`technician_id`), FOREIGN KEY (`repair_ID`) REFERENCES `repair`(`repair_ID`), FOREIGN KEY (`Machine_ID`) REFERENCES `machine`(`Machine_ID`) ); INSERT INTO "repair" VALUES (1,"Discoverer","21 Jan 2009","repair Failed. Failed to achieve orbit"); INSERT INTO "machine" VALUES (1,"1991","125cc","Hero Sports TS- Honda","RS125","105",2); INSERT INTO "technician" VALUES ("1","Joe Sewell","NYY","2012",37); INSERT INTO "repair_assignment" VALUES (1,1,1);
machine_repair
SELECT Team FROM technician GROUP BY Team ORDER BY COUNT(*) DESC LIMIT 1
Please show the team that has the most number of technicians.
CREATE TABLE "repair" ( "repair_ID" int, "name" text, "Launch_Date" text, "Notes" text, PRIMARY KEY ("repair_ID") ); CREATE TABLE "machine" ( "Machine_ID" int, "Making_Year" int, "Class" text, "Team" text, "Machine_series" text, "value_points" real, "quality_rank" int, PRIMARY KEY ("Machine_ID") ); CREATE TABLE "technician" ( "technician_id" real, "Name" text, "Team" text, "Starting_Year" real, "Age" int, PRIMARY Key ("technician_id") ); CREATE TABLE "repair_assignment" ( "technician_id" int, "repair_ID" int, "Machine_ID" int, PRIMARY Key ("technician_id","repair_ID","Machine_ID"), FOREIGN KEY (`technician_id`) REFERENCES `technician`(`technician_id`), FOREIGN KEY (`repair_ID`) REFERENCES `repair`(`repair_ID`), FOREIGN KEY (`Machine_ID`) REFERENCES `machine`(`Machine_ID`) ); INSERT INTO "repair" VALUES (1,"Discoverer","21 Jan 2009","repair Failed. Failed to achieve orbit"); INSERT INTO "machine" VALUES (1,"1991","125cc","Hero Sports TS- Honda","RS125","105",2); INSERT INTO "technician" VALUES ("1","Joe Sewell","NYY","2012",37); INSERT INTO "repair_assignment" VALUES (1,1,1);