db_id
stringclasses 127
values | query
stringlengths 20
523
| question
stringlengths 16
224
| schema
stringclasses 127
values |
---|---|---|---|
store_product | SELECT t3.headquartered_city FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id WHERE t1.store_name = "Blackville" | Which city is the headquarter of the store named "Blackville" in? |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT t3.headquartered_city FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id WHERE t1.store_name = "Blackville" | What city is the headquarter of the store Blackville? |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT t3.headquartered_city , count(*) FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id GROUP BY t3.headquartered_city | Find the number of stores in each city. |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT t3.headquartered_city , count(*) FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id GROUP BY t3.headquartered_city | How many stores are headquarted in each city? |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT t3.headquartered_city FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id GROUP BY t3.headquartered_city ORDER BY count(*) DESC LIMIT 1 | Find the city with the most number of stores. |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT t3.headquartered_city FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id GROUP BY t3.headquartered_city ORDER BY count(*) DESC LIMIT 1 | What is the city with the most number of flagship stores? |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT avg(pages_per_minute_color) FROM product | What is the average pages per minute color? |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT avg(pages_per_minute_color) FROM product | What is the average number of pages per minute color? |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT t1.product FROM product AS t1 JOIN store_product AS t2 ON t1.product_id = t2.product_id JOIN store AS t3 ON t2.store_id = t3.store_id WHERE t3.store_name = "Miramichi" | What products are available at store named "Miramichi"? |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT t1.product FROM product AS t1 JOIN store_product AS t2 ON t1.product_id = t2.product_id JOIN store AS t3 ON t2.store_id = t3.store_id WHERE t3.store_name = "Miramichi" | What products are sold at the store named Miramichi? |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT product FROM product WHERE max_page_size = "A4" AND pages_per_minute_color < 5 | Find products with max page size as "A4" and pages per minute color smaller than 5. |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT product FROM product WHERE max_page_size = "A4" AND pages_per_minute_color < 5 | What are the products with the maximum page size A4 that also have a pages per minute color smaller than 5? |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT product FROM product WHERE max_page_size = "A4" OR pages_per_minute_color < 5 | Find products with max page size as "A4" or pages per minute color smaller than 5. |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT product FROM product WHERE max_page_size = "A4" OR pages_per_minute_color < 5 | What are the products with the maximum page size eqal to A4 or a pages per minute color less than 5? |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT product FROM product WHERE product LIKE "%Scanner%" | Find all the product whose name contains the word "Scanner". |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT product FROM product WHERE product LIKE "%Scanner%" | What are all of the products whose name includes the substring "Scanner"? |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT max_page_size FROM product GROUP BY max_page_size ORDER BY count(*) DESC LIMIT 1 | Find the most prominent max page size among all the products. |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT max_page_size FROM product GROUP BY max_page_size ORDER BY count(*) DESC LIMIT 1 | What is the most common maximum page size? |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT product FROM product WHERE product != (SELECT max_page_size FROM product GROUP BY max_page_size ORDER BY count(*) DESC LIMIT 1) | Find the name of the products that are not using the most frequently-used max page size. |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT product FROM product WHERE product != (SELECT max_page_size FROM product GROUP BY max_page_size ORDER BY count(*) DESC LIMIT 1) | What are the names of all products that are not the most frequently-used maximum page size? |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT sum(city_population) FROM district WHERE city_area > (SELECT avg(city_area) FROM district) | Find the total population of the districts where the area is bigger than the average city area. |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT sum(city_population) FROM district WHERE city_area > (SELECT avg(city_area) FROM district) | What is the total population for all the districts that have an area larger tahn the average city area? |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT t3.District_name FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id WHERE t1.Type = "City Mall" INTERSECT SELECT t3.District_name FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id WHERE t1.Type = "Village Store" | Find the names of districts where have both city mall and village store type stores. |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
store_product | SELECT t3.District_name FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id WHERE t1.Type = "City Mall" INTERSECT SELECT t3.District_name FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id WHERE t1.Type = "Village Store" | What are the names of the districts that have both mall and village store style shops? |
PRAGMA foreign_keys = ON;
CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);
CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);
CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);
CREATE TABLE "store_product" (
"Store_ID" int,
"Product_ID" int,
PRIMARY KEY ("Store_ID","Product_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`Product_ID`) REFERENCES `product`(`Product_ID`)
);
CREATE TABLE "store_district" (
"Store_ID" int,
"District_ID" int,
PRIMARY KEY ("Store_ID"),
FOREIGN KEY (`Store_ID`) REFERENCES `store`(`Store_ID`),
FOREIGN KEY (`District_ID`) REFERENCES `district`(`District_ID`)
);
INSERT INTO "product" VALUES (1,"Fujitsu fi-6130 A4 Series Scanner","301 x 160 x 158","600","30","A4","USB 2.0");
INSERT INTO "store" VALUES (1,"Miramichi","City Mall","179.84","17811","2");
INSERT INTO "district" VALUES ("1","Attock District","Attock City","94620","20");
INSERT INTO "store_product" VALUES (1,1);
INSERT INTO "store_district" VALUES (1,15);
|
soccer_2 | SELECT sum(enr) FROM College | What is the total enrollment number of all colleges? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT sum(enr) FROM College | How many students are enrolled in college? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT avg(enr) FROM College | What is the average enrollment number? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT avg(enr) FROM College | How many students, on average, does each college have enrolled? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT count(*) FROM College | How many colleges in total? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT count(*) FROM College | How many different colleges are there? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT count(*) FROM Player WHERE HS > 1000 | How many players have more than 1000 hours of training? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT count(*) FROM Player WHERE HS > 1000 | How many different players trained for more than 1000 hours? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT count(*) FROM College WHERE enr > 15000 | How many colleges has more than 15000 students? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT count(*) FROM College WHERE enr > 15000 | What is the number of colleges with a student population greater than 15000? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT avg(HS) FROM Player | What is the average training hours of all players? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT avg(HS) FROM Player | How many hours do the players train on average? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT pName , HS FROM Player WHERE HS < 1500 | Find the name and training hours of players whose hours are below 1500. | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT pName , HS FROM Player WHERE HS < 1500 | What are the names and number of hours spent training for each player who trains for less than 1500 hours? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT count(DISTINCT cName) FROM tryout | How many different colleges do attend the tryout test? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT count(DISTINCT cName) FROM tryout | How many different colleges were represented at tryouts? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT count(DISTINCT pPos) FROM tryout | What are the unique types of player positions in the tryout? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT count(DISTINCT pPos) FROM tryout | What are the different types of player positions? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT count(*) FROM tryout WHERE decision = 'yes' | How many students got accepted after the tryout? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT count(*) FROM tryout WHERE decision = 'yes' | How many students received a yes from tryouts? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT count(*) FROM tryout WHERE pPos = 'goalie' | How many students whose are playing the role of goalie? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT count(*) FROM tryout WHERE pPos = 'goalie' | What is the number of students playing as a goalie? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT avg(HS) , max(HS) , min(HS) FROM Player | Find the max, average and min training hours of all players. | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT avg(HS) , max(HS) , min(HS) FROM Player | What is the average, maximum, and minimum for the number of hours spent training? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT avg(enr) FROM College WHERE state = 'FL' | What is average enrollment of colleges in the state FL? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT avg(enr) FROM College WHERE state = 'FL' | What is average number of students enrolled in Florida colleges? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT pName FROM Player WHERE HS BETWEEN 500 AND 1500 | What are the names of players whose training hours is between 500 and 1500? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT pName FROM Player WHERE HS BETWEEN 500 AND 1500 | What are the names of players who train between 500 and 1500 hours? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT DISTINCT pName FROM Player WHERE pName LIKE '%a%' | Find the players whose names contain letter 'a'. | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT DISTINCT pName FROM Player WHERE pName LIKE '%a%' | Who are the players that have names containing the letter a? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT cName , enr FROM College WHERE enr > 10000 AND state = "LA" | Find the name, enrollment of the colleges whose size is bigger than 10000 and location is in state LA. | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT cName , enr FROM College WHERE enr > 10000 AND state = "LA" | What are the names and enrollment numbers for colleges that have more than 10000 enrolled and are located in Louisiana? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT * FROM College ORDER BY enr | List all information about college sorted by enrollment number in the ascending order. | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT * FROM College ORDER BY enr | What information do you have on colleges sorted by increasing enrollment numbers? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT cName FROM College WHERE enr > 18000 ORDER BY cName | List the name of the colleges whose enrollment is greater 18000 sorted by the college's name. | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT cName FROM College WHERE enr > 18000 ORDER BY cName | What is the name of every college in alphabetical order that has more than 18000 students enrolled? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT pName FROM Player WHERE yCard = 'yes' ORDER BY HS DESC | Find the name of players whose card is yes in the descending order of training hours. | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT pName FROM Player WHERE yCard = 'yes' ORDER BY HS DESC | What are the name of the players who received a card in descending order of the hours of training? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT DISTINCT cName FROM tryout ORDER BY cName | Find the name of different colleges involved in the tryout in alphabetical order. | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT DISTINCT cName FROM tryout ORDER BY cName | What are the different names of the colleges involved in the tryout in alphabetical order? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT pPos FROM tryout GROUP BY pPos ORDER BY count(*) DESC LIMIT 1 | Which position is most popular among players in the tryout? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT pPos FROM tryout GROUP BY pPos ORDER BY count(*) DESC LIMIT 1 | What was the most popular position at tryouts? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT count(*) , cName FROM tryout GROUP BY cName ORDER BY count(*) DESC | Find the number of students who participate in the tryout for each college ordered by descending count. | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT count(*) , cName FROM tryout GROUP BY cName ORDER BY count(*) DESC | How many students participated in tryouts for each college by descennding count? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT min(T2.HS) , T1.pPos FROM tryout AS T1 JOIN player AS T2 ON T1.pID = T2.pID GROUP BY T1.pPos | What is minimum hours of the students playing in different position? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT min(T2.HS) , T1.pPos FROM tryout AS T1 JOIN player AS T2 ON T1.pID = T2.pID GROUP BY T1.pPos | For each position, what is the minimum time students spent practicing? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT cName FROM college ORDER BY enr DESC LIMIT 3 | What are the names of schools with the top 3 largest size? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT cName FROM college ORDER BY enr DESC LIMIT 3 | What are the names of the schools with the top 3 largest class sizes? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT cName , state , min(enr) FROM college GROUP BY state | What is the name of school that has the smallest enrollment in each state? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT cName , state , min(enr) FROM college GROUP BY state | What is the name of the school with smallest enrollment size per state? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT DISTINCT state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName | Find the states where have some college students in tryout. | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT DISTINCT state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName | What are the different states that have students trying out? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT DISTINCT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.decision = 'yes' | Find the states where have some college students in tryout and their decisions are yes. | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT DISTINCT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.decision = 'yes' | What are the different states that had students successfully try out? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT T1.pName , T2.cName FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'yes' | Find the name and college of students whose decisions are yes in the tryout. | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT T1.pName , T2.cName FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'yes' | What are the names of all the players who received a yes during tryouts, and also what are the names of their colleges? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT T1.pName FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID ORDER BY T1.pName | Find the name of all students who were in the tryout sorted in alphabetic order. | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT T1.pName FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID ORDER BY T1.pName | What are the names of all students who tried out in alphabetical order? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT T1.pName , T1.HS FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'yes' | Find the name and hours of the students whose tryout decision is yes. | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT T1.pName , T1.HS FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'yes' | What are the names and hours spent practicing of every student who received a yes at tryouts? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'striker' | Find the states of the colleges that have students in the tryout who played in striker position. | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'striker' | What are the states of the colleges where students who tried out for the striker position attend? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT T1.pName FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'yes' AND T2.pPos = 'striker' | Find the names of the students who are in the position of striker and got a yes tryout decision. | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT T1.pName FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'yes' AND T2.pPos = 'striker' | What are the names of all students who successfully tried out for the position of striker? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName JOIN player AS T3 ON T2.pID = T3.pID WHERE T3.pName = 'Charles' | Find the state of the college which player Charles is attending. | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName JOIN player AS T3 ON T2.pID = T3.pID WHERE T3.pName = 'Charles' | In which state is the college that Charles attends? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT avg(T1.HS) , max(T1.HS) FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'yes' | Find the average and maximum hours for the students whose tryout decision is yes. | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT avg(T1.HS) , max(T1.HS) FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'yes' | What is the average and maximum number of hours students who made the team practiced? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT avg(T1.HS) FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'no' | Find the average hours for the students whose tryout decision is no. | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT avg(T1.HS) FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'no' | What is the average number of hours spent practicing for students who got rejected? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT max(T1.HS) , pPos FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T1.HS > 1000 GROUP BY T2.pPos | What is the maximum training hours for the students whose training hours is greater than 1000 in different positions? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT max(T1.HS) , pPos FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T1.HS > 1000 GROUP BY T2.pPos | For each position, what is the maximum number of hours for students who spent more than 1000 hours training? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT T1.cName FROM tryout AS T1 JOIN player AS T2 ON T1.pID = T2.pID WHERE T2.pName LIKE 'D%' | Which colleges do the tryout players whose name starts with letter D go to? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT T1.cName FROM tryout AS T1 JOIN player AS T2 ON T1.pID = T2.pID WHERE T2.pName LIKE 'D%' | Which colleges does each player with a name that starts with the letter D who tried out go to? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT cName FROM tryout WHERE decision = 'yes' AND pPos = 'goalie' | Which college has any student who is a goalie and succeeded in the tryout. | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
soccer_2 | SELECT cName FROM tryout WHERE decision = 'yes' AND pPos = 'goalie' | What college has a student who successfully made the team in the role of a goalie? | /*
* SQL scripts for CS61 Intro to SQL lectures
* FILENAME SOCCER2.SQL
*/
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Tryout;
DROP TABLE IF EXISTS College;
CREATE TABLE College
( cName varchar(20) NOT NULL,
state varchar(2),
enr numeric(5,0),
PRIMARY KEY (cName)
);
CREATE TABLE Player
( pID numeric(5,0) NOT NULL,
pName varchar(20),
yCard varchar(3),
HS numeric(5,0),
PRIMARY KEY (pID)
);
CREATE TABLE Tryout
( pID numeric(5,0),
cName varchar(20),
pPos varchar(8),
decision varchar(3),
PRIMARY KEY (pID, cName),
FOREIGN KEY (pID) REFERENCES Player(pID),
FOREIGN KEY (cName) REFERENCES College(cName)
);
/* note that "left" and "right" are reserved words in SQL */
INSERT INTO College VALUES ('LSU', 'LA', 18000);
INSERT INTO Player VALUES (10001, 'Andrew', 'no', 1200);
INSERT INTO Tryout VALUES (10001, 'LSU', 'goalie', 'no');
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.