Search is not available for this dataset
db_id stringlengths 3 31 | query stringlengths 20 523 | question stringlengths 3 224 | schema stringlengths 589 322M | query_res stringlengths 0 363k |
|---|---|---|---|---|
swimming | SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id GROUP BY t2.swimmer_id ORDER BY count(*) DESC LIMIT 1 | Find the name of the swimmer who has the most records. |
PRAGMA foreign_keys = ON;
CREATE TABLE "swimmer" (
"ID" int,
"name" text,
"Nationality" text,
"meter_100" real,
"meter_200" text,
"meter_300" text,
"meter_400" text,
"meter_500" text,
"meter_600" text,
"meter_700" text,
"Time" text,
PRIMARY KEY ("ID")
);
INSERT INTO "swimmer" VALUES ("7","Przemysław Stańczyk","Po... | ('Craig Stevens',)
|
swimming | SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id GROUP BY t2.swimmer_id HAVING count(*) >= 2 | Find the name of the swimmer who has at least 2 records. |
PRAGMA foreign_keys = ON;
CREATE TABLE "swimmer" (
"ID" int,
"name" text,
"Nationality" text,
"meter_100" real,
"meter_200" text,
"meter_300" text,
"meter_400" text,
"meter_500" text,
"meter_600" text,
"meter_700" text,
"Time" text,
PRIMARY KEY ("ID")
);
INSERT INTO "swimmer" VALUES ("7","Przemysław Stańczyk","Po... | ('Sergiy Fesenko',)
('Oussama Mellouli',)
('Craig Stevens',)
|
swimming | SELECT t1.name , t1.nationality FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Win' GROUP BY t2.swimmer_id HAVING count(*) > 1 | Find the name and nationality of the swimmer who has won (i.e., has a result of "win") more than 1 time. |
PRAGMA foreign_keys = ON;
CREATE TABLE "swimmer" (
"ID" int,
"name" text,
"Nationality" text,
"meter_100" real,
"meter_200" text,
"meter_300" text,
"meter_400" text,
"meter_500" text,
"meter_600" text,
"meter_700" text,
"Time" text,
PRIMARY KEY ("ID")
);
INSERT INTO "swimmer" VALUES ("7","Przemysław Stańczyk","Po... | ('Oussama Mellouli', 'Tunisia')
('Craig Stevens', 'Australia')
|
swimming | SELECT name FROM swimmer WHERE id NOT IN (SELECT swimmer_id FROM record) | Find the names of the swimmers who have no record. |
PRAGMA foreign_keys = ON;
CREATE TABLE "swimmer" (
"ID" int,
"name" text,
"Nationality" text,
"meter_100" real,
"meter_200" text,
"meter_300" text,
"meter_400" text,
"meter_500" text,
"meter_600" text,
"meter_700" text,
"Time" text,
PRIMARY KEY ("ID")
);
INSERT INTO "swimmer" VALUES ("7","Przemysław Stańczyk","Po... | ('Przemysław Stańczyk',)
('Sébastien Rouault',)
|
swimming | SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Win' INTERSECT SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Loss' | Find the names of the swimmers who have both "win" and "loss" results in the record. |
PRAGMA foreign_keys = ON;
CREATE TABLE "swimmer" (
"ID" int,
"name" text,
"Nationality" text,
"meter_100" real,
"meter_200" text,
"meter_300" text,
"meter_400" text,
"meter_500" text,
"meter_600" text,
"meter_700" text,
"Time" text,
PRIMARY KEY ("ID")
);
INSERT INTO "swimmer" VALUES ("7","Przemysław Stańczyk","Po... | ('Craig Stevens',)
('Oussama Mellouli',)
('Sergiy Fesenko',)
|
swimming | SELECT t4.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id JOIN event AS t3 ON t2.event_id = t3.id JOIN stadium AS t4 ON t4.id = t3.stadium_id WHERE t1.nationality = 'Australia' | Find the names of stadiums that some Australian swimmers have been to. |
PRAGMA foreign_keys = ON;
CREATE TABLE "swimmer" (
"ID" int,
"name" text,
"Nationality" text,
"meter_100" real,
"meter_200" text,
"meter_300" text,
"meter_400" text,
"meter_500" text,
"meter_600" text,
"meter_700" text,
"Time" text,
PRIMARY KEY ("ID")
);
INSERT INTO "swimmer" VALUES ("7","Przemysław Stańczyk","Po... | ('Nou Mestalla',)
('Nou Mestalla',)
('Yubileyniy Stadium',)
('Gazprom Arena',)
('Baku Olympic Stadium',)
|
swimming | SELECT t3.name FROM record AS t1 JOIN event AS t2 ON t1.event_id = t2.id JOIN stadium AS t3 ON t3.id = t2.stadium_id GROUP BY t2.stadium_id ORDER BY count(*) DESC LIMIT 1 | Find the names of stadiums that the most swimmers have been to. |
PRAGMA foreign_keys = ON;
CREATE TABLE "swimmer" (
"ID" int,
"name" text,
"Nationality" text,
"meter_100" real,
"meter_200" text,
"meter_300" text,
"meter_400" text,
"meter_500" text,
"meter_600" text,
"meter_700" text,
"Time" text,
PRIMARY KEY ("ID")
);
INSERT INTO "swimmer" VALUES ("7","Przemysław Stańczyk","Po... | ('Gazprom Arena',)
|
swimming | SELECT * FROM swimmer | Find all details for each swimmer. |
PRAGMA foreign_keys = ON;
CREATE TABLE "swimmer" (
"ID" int,
"name" text,
"Nationality" text,
"meter_100" real,
"meter_200" text,
"meter_300" text,
"meter_400" text,
"meter_500" text,
"meter_600" text,
"meter_700" text,
"Time" text,
PRIMARY KEY ("ID")
);
INSERT INTO "swimmer" VALUES ("7","Przemysław Stańczyk","Po... | (7, 'Przemysław Stańczyk', 'Poland', 57.31, '1:57.10', '2:56.02', '3:55.36', '4:54.21', '5:52.59', '6:50.91', '7:47.91')
(4, 'Craig Stevens', 'Australia', 57.35, '1:56.34', '2:55.90', '3:55.72', '4:55.08', '5:54.45', '6:52.69', '7:48.67')
(5, 'Federico Colbertaldo', 'Italy', 57.66, '1:56.77', '2:56.04', '3:55.37', '4:5... |
swimming | SELECT avg(capacity) FROM stadium WHERE opening_year = 2005 | What is the average capacity of the stadiums that were opened in year 2005? |
PRAGMA foreign_keys = ON;
CREATE TABLE "swimmer" (
"ID" int,
"name" text,
"Nationality" text,
"meter_100" real,
"meter_200" text,
"meter_300" text,
"meter_400" text,
"meter_500" text,
"meter_600" text,
"meter_700" text,
"Time" text,
PRIMARY KEY ("ID")
);
INSERT INTO "swimmer" VALUES ("7","Przemysław Stańczyk","Po... | (62504.0,)
|
railway | SELECT count(*) FROM railway | How many railways are there? |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | (10,)
|
railway | SELECT Builder FROM railway ORDER BY Builder ASC | List the builders of railways in ascending alphabetical order. |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | ('Avonside',)
('GER Hartford',)
('GER Stratford',)
('GNR Doncaster',)
('GWR Swindon',)
('GWR Swindon',)
('MR Derby',)
('SECR Ashford',)
('Stephenson',)
('Swindon Works',)
|
railway | SELECT Wheels , LOCATION FROM railway | List the wheels and locations of the railways. |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | ('4-4-0', 'York')
('4-4-0', "Bo'ness")
('4-4-2', 'Barrow Hill')
('4-4-0', 'Toddington')
('0-6-0T', 'Bressingham')
('0-6-0', 'Barrow Hill')
('2-8-0', 'Shildon')
('4-6-0', 'Swindon')
('4-4-2T', 'Bressingham')
('0-6-0ST', 'Basingstoke')
|
railway | SELECT max(LEVEL) FROM manager WHERE Country != "Australia " | What is the maximum level of managers in countries that are not "Australia"? |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | (12,)
|
railway | SELECT avg(Age) FROM manager | What is the average age for all managers? |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | (49.142857142857146,)
|
railway | SELECT Name FROM manager ORDER BY LEVEL ASC | What are the names of managers in ascending order of level? |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | ('Ben Curtis',)
('Todd Hamilton',)
('Tiger Woods',)
('David Duval',)
('Sandy Lyle',)
('Nick Faldo',)
('Greg Norman',)
|
railway | SELECT Name , Arrival FROM train | What are the names and arrival times of trains? |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | ('Wardha-Ballarshah Pass', '08:54')
('Sewagram Exp', '09:08')
('Ballarshah-Mumbai Pass', '09:48')
('Nagpur-Kazipet Pass', '23:44')
('Kazipet-Nagpur Pass', '05:09')
('Lucknow-Chennai Exp', '13:04')
('Andaman Exp', '13:04')
('Andaman Exp', '23:39')
('Nandigram Exp', '13:28')
|
railway | SELECT Name FROM manager ORDER BY Age DESC LIMIT 1 | What is the name of the oldest manager? |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | ('Todd Hamilton',)
|
railway | SELECT T2.Name , T1.Location FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID | Show the names of trains and locations of railways they are in. |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | ('Wardha-Ballarshah Pass', 'York')
('Sewagram Exp', 'York')
('Ballarshah-Mumbai Pass', "Bo'ness")
('Nagpur-Kazipet Pass', 'Barrow Hill')
('Kazipet-Nagpur Pass', 'Bressingham')
('Lucknow-Chennai Exp', 'Bressingham')
('Andaman Exp', 'Shildon')
('Andaman Exp', 'Bressingham')
('Nandigram Exp', 'Basingstoke')
|
railway | SELECT T1.Builder FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID WHERE T2.Name = "Andaman Exp" | Show the builder of railways associated with the trains named "Andaman Exp". |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | ('GWR Swindon',)
('Stephenson',)
|
railway | SELECT T2.Railway_ID , T1.Location FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID GROUP BY T2.Railway_ID HAVING COUNT(*) > 1 | Show id and location of railways that are associated with more than one train. |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | (1, 'York')
(5, 'Bressingham')
|
railway | SELECT T2.Railway_ID , T1.Builder FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID GROUP BY T2.Railway_ID ORDER BY COUNT(*) DESC LIMIT 1 | Show the id and builder of the railway that are associated with the most trains. |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | (5, 'GER Stratford')
|
railway | SELECT Builder , COUNT(*) FROM railway GROUP BY Builder | Show different builders of railways, along with the corresponding number of railways using each builder. |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | ('Avonside', 1)
('GER Hartford', 1)
('GER Stratford', 1)
('GNR Doncaster', 1)
('GWR Swindon', 2)
('MR Derby', 1)
('SECR Ashford', 1)
('Stephenson', 1)
('Swindon Works', 1)
|
railway | SELECT Builder FROM railway GROUP BY Builder ORDER BY COUNT(*) DESC LIMIT 1 | Show the most common builder of railways. |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | ('GWR Swindon',)
|
railway | SELECT LOCATION , COUNT(*) FROM railway GROUP BY LOCATION | Show different locations of railways along with the corresponding number of railways at each location. |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | ('Barrow Hill', 2)
('Basingstoke', 1)
("Bo'ness", 1)
('Bressingham', 2)
('Shildon', 1)
('Swindon', 1)
('Toddington', 1)
('York', 1)
|
railway | SELECT LOCATION FROM railway GROUP BY LOCATION HAVING COUNT(*) > 1 | Show the locations that have more than one railways. |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | ('Barrow Hill',)
('Bressingham',)
|
railway | SELECT ObjectNumber FROM railway WHERE Railway_ID NOT IN (SELECT Railway_ID FROM train) | List the object number of railways that do not have any trains. |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | ('1978-7025',)
('1978-7026',)
('1978-7027',)
|
railway | SELECT Country FROM manager WHERE Age > 50 INTERSECT SELECT Country FROM manager WHERE Age < 46 | Show the countries that have both managers of age above 50 and managers of age below 46. |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | ('United States',)
|
railway | SELECT DISTINCT Country FROM manager | Show the distinct countries of managers. |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | ('United States',)
('Scotland',)
('England',)
('Australia',)
|
railway | SELECT Working_year_starts FROM manager ORDER BY LEVEL DESC | Show the working years of managers in descending order of their level. |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | ('1993',)
('1999',)
('1985',)
('2001',)
('2003',)
('2004',)
('2006',)
|
railway | SELECT Country FROM manager WHERE Age > 50 OR Age < 46 | Show the countries that have managers of age above 50 or below 46. |
PRAGMA foreign_keys = ON;
CREATE TABLE "railway" (
"Railway_ID" int,
"Railway" text,
"Builder" text,
"Built" text,
"Wheels" text,
"Location" text,
"ObjectNumber" text,
PRIMARY KEY ("Railway_ID")
);
INSERT INTO "railway" VALUES (1,"SECR","SECR Ashford","1901","4-4-0","York","1975-7006");
INSERT INTO "railway" VAL... | ('United States',)
('United States',)
('England',)
('Australia',)
|
customers_and_products_contacts | SELECT count(*) FROM addresses WHERE country = 'USA' | How many addresses are there in country USA? | PRAGMA foreign_keys = ON;
CREATE TABLE `Addresses` (
`address_id` INTEGER PRIMARY KEY,
`line_1_number_building` VARCHAR(80),
`city` VARCHAR(50),
`zip_postcode` VARCHAR(20),
`state_province_county` VARCHAR(50),
`country` VARCHAR(50)
);
INSERT INTO Addresses (`address_id`, `line_1_number_building`, `city`, `zip_postcode... | (15,)
|
customers_and_products_contacts | SELECT DISTINCT city FROM addresses | Show all distinct cities in the address record. | PRAGMA foreign_keys = ON;
CREATE TABLE `Addresses` (
`address_id` INTEGER PRIMARY KEY,
`line_1_number_building` VARCHAR(80),
`city` VARCHAR(50),
`zip_postcode` VARCHAR(20),
`state_province_county` VARCHAR(50),
`country` VARCHAR(50)
);
INSERT INTO Addresses (`address_id`, `line_1_number_building`, `city`, `zip_postcode... | ('Hertafurt',)
('Edgardoberg',)
('Gilbertmouth',)
('Lake Floyd',)
('Gibsonfurt',)
('North Jairo',)
('East Rickey',)
('West Kaiatown',)
('Agustinstad',)
('Gleasonland',)
('Lake Katheryn',)
('North Lisandroport',)
('Estaland',)
('West Muriel',)
('Port Montytown',)
|
customers_and_products_contacts | SELECT state_province_county , count(*) FROM addresses GROUP BY state_province_county | Show each state and the number of addresses in each state. | PRAGMA foreign_keys = ON;
CREATE TABLE `Addresses` (
`address_id` INTEGER PRIMARY KEY,
`line_1_number_building` VARCHAR(80),
`city` VARCHAR(50),
`zip_postcode` VARCHAR(20),
`state_province_county` VARCHAR(50),
`country` VARCHAR(50)
);
INSERT INTO Addresses (`address_id`, `line_1_number_building`, `city`, `zip_postcode... | ('Colorado', 1)
('District of Columbia', 1)
('Idaho', 1)
('Illinois', 1)
('Kentucky', 2)
('Louisiana', 1)
('Maine', 1)
('Maryland', 1)
('Nevada', 1)
('Oklahoma', 1)
('Oregon', 1)
('SouthDakota', 1)
('Vermont', 1)
('Virginia', 1)
|
customers_and_products_contacts | SELECT customer_name , customer_phone FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM customer_address_history) | Show names and phones of customers who do not have address information. | PRAGMA foreign_keys = ON;
CREATE TABLE `Addresses` (
`address_id` INTEGER PRIMARY KEY,
`line_1_number_building` VARCHAR(80),
`city` VARCHAR(50),
`zip_postcode` VARCHAR(20),
`state_province_county` VARCHAR(50),
`country` VARCHAR(50)
);
INSERT INTO Addresses (`address_id`, `line_1_number_building`, `city`, `zip_postcode... | ('Kayley', '+87(9)5279161988')
('Caterina', '387.053.1225')
('Raymond', '1-513-427-0125')
('Brenna', '1-271-345-4681x1131')
('Cleo', '1-202-928-5395')
('Ottilie', '393-750-2077x72779')
|
customers_and_products_contacts | SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1 | Show the name of the customer who has the most orders. | PRAGMA foreign_keys = ON;
CREATE TABLE `Addresses` (
`address_id` INTEGER PRIMARY KEY,
`line_1_number_building` VARCHAR(80),
`city` VARCHAR(50),
`zip_postcode` VARCHAR(20),
`state_province_county` VARCHAR(50),
`country` VARCHAR(50)
);
INSERT INTO Addresses (`address_id`, `line_1_number_building`, `city`, `zip_postcode... | ('Cleo',)
|
customers_and_products_contacts | SELECT product_type_code FROM products GROUP BY product_type_code HAVING count(*) >= 2 | Show the product type codes which have at least two products. | PRAGMA foreign_keys = ON;
CREATE TABLE `Addresses` (
`address_id` INTEGER PRIMARY KEY,
`line_1_number_building` VARCHAR(80),
`city` VARCHAR(50),
`zip_postcode` VARCHAR(20),
`state_province_county` VARCHAR(50),
`country` VARCHAR(50)
);
INSERT INTO Addresses (`address_id`, `line_1_number_building`, `city`, `zip_postcode... | ('Clothes',)
('Hardware',)
|
customers_and_products_contacts | SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = 'Completed' INTERSECT SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = 'Part' | Show the names of customers who have both an order in completed status and an order in part status. | PRAGMA foreign_keys = ON;
CREATE TABLE `Addresses` (
`address_id` INTEGER PRIMARY KEY,
`line_1_number_building` VARCHAR(80),
`city` VARCHAR(50),
`zip_postcode` VARCHAR(20),
`state_province_county` VARCHAR(50),
`country` VARCHAR(50)
);
INSERT INTO Addresses (`address_id`, `line_1_number_building`, `city`, `zip_postcode... | ('Cleo',)
('Lela',)
('Sterling',)
|
customers_and_products_contacts | SELECT customer_name , customer_phone , payment_method_code FROM customers ORDER BY customer_number DESC | Show the name, phone, and payment method code for all customers in descending order of customer number. | PRAGMA foreign_keys = ON;
CREATE TABLE `Addresses` (
`address_id` INTEGER PRIMARY KEY,
`line_1_number_building` VARCHAR(80),
`city` VARCHAR(50),
`zip_postcode` VARCHAR(20),
`state_province_county` VARCHAR(50),
`country` VARCHAR(50)
);
INSERT INTO Addresses (`address_id`, `line_1_number_building`, `city`, `zip_postcode... | ('Buford', '(192)144-4687', 'Credit Card')
('Cheyenne', '009-136-4509x19635', 'Direct Debit')
('Cleo', '1-202-928-5395', 'Credit Card')
('Raymond', '1-513-427-0125', 'Direct Debit')
('Orion', '479-171-6355x66065', 'Direct Debit')
('Madaline', '097-514-4641', 'Credit Card')
('Brenna', '1-271-345-4681x1131', 'Credit Card... |
customers_and_products_contacts | SELECT T1.product_name , sum(T2.order_quantity) FROM products AS T1 JOIN order_items AS T2 ON T1.product_id = T2.product_id GROUP BY T1.product_id | Show the product name and total order quantity for each product. | PRAGMA foreign_keys = ON;
CREATE TABLE `Addresses` (
`address_id` INTEGER PRIMARY KEY,
`line_1_number_building` VARCHAR(80),
`city` VARCHAR(50),
`zip_postcode` VARCHAR(20),
`state_province_county` VARCHAR(50),
`country` VARCHAR(50)
);
INSERT INTO Addresses (`address_id`, `line_1_number_building`, `city`, `zip_postcode... | ('jcrew', 14.0)
('Apple', 11)
('Apple', 8)
('jcrew', 9)
('Apple', 4)
('jcrew', 9)
('jcrew', 8)
('gucci', 12)
('gucci', 4)
('gucci', 5)
|
customers_and_products_contacts | SELECT min(product_price) , max(product_price) , avg(product_price) FROM products | Show the minimum, maximum, average price for all products. | PRAGMA foreign_keys = ON;
CREATE TABLE `Addresses` (
`address_id` INTEGER PRIMARY KEY,
`line_1_number_building` VARCHAR(80),
`city` VARCHAR(50),
`zip_postcode` VARCHAR(20),
`state_province_county` VARCHAR(50),
`country` VARCHAR(50)
);
INSERT INTO Addresses (`address_id`, `line_1_number_building`, `city`, `zip_postcode... | (77.109961147471, 310488248.48788, 28612946.784182724)
|
customers_and_products_contacts | SELECT count(*) FROM products WHERE product_price > (SELECT avg(product_price) FROM products) | How many products have a price higher than the average? | PRAGMA foreign_keys = ON;
CREATE TABLE `Addresses` (
`address_id` INTEGER PRIMARY KEY,
`line_1_number_building` VARCHAR(80),
`city` VARCHAR(50),
`zip_postcode` VARCHAR(20),
`state_province_county` VARCHAR(50),
`country` VARCHAR(50)
);
INSERT INTO Addresses (`address_id`, `line_1_number_building`, `city`, `zip_postcode... | (3,)
|
customers_and_products_contacts | SELECT T2.customer_name , T3.city , T1.date_from , T1.date_to FROM customer_address_history AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id JOIN addresses AS T3 ON T1.address_id = T3.address_id | Show the customer name, customer address city, date from, and date to for each customer address history. | PRAGMA foreign_keys = ON;
CREATE TABLE `Addresses` (
`address_id` INTEGER PRIMARY KEY,
`line_1_number_building` VARCHAR(80),
`city` VARCHAR(50),
`zip_postcode` VARCHAR(20),
`state_province_county` VARCHAR(50),
`country` VARCHAR(50)
);
INSERT INTO Addresses (`address_id`, `line_1_number_building`, `city`, `zip_postcode... | ('Madaline', 'East Rickey', '2015-07-23 14:37:18', '2018-03-07 12:04:20')
('Madaline', 'Edgardoberg', '2016-11-06 14:33:12', '2018-03-14 21:36:28')
('Buford', 'Agustinstad', '2011-11-19 12:17:36', '2018-03-22 10:20:16')
('Melissa', 'Port Montytown', '2009-02-16 23:04:20', '2018-03-07 17:47:47')
('Buford', 'North Lisand... |
customers_and_products_contacts | SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.payment_method_code = 'Credit Card' GROUP BY T1.customer_id HAVING count(*) > 2 | Show the names of customers who use Credit Card payment method and have more than 2 orders. | PRAGMA foreign_keys = ON;
CREATE TABLE `Addresses` (
`address_id` INTEGER PRIMARY KEY,
`line_1_number_building` VARCHAR(80),
`city` VARCHAR(50),
`zip_postcode` VARCHAR(20),
`state_province_county` VARCHAR(50),
`country` VARCHAR(50)
);
INSERT INTO Addresses (`address_id`, `line_1_number_building`, `city`, `zip_postcode... | ('Sterling',)
('Cleo',)
|
customers_and_products_contacts | SELECT T1.customer_name , T1.customer_phone FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id JOIN order_items AS T3 ON T3.order_id = T2.order_id GROUP BY T1.customer_id ORDER BY sum(T3.order_quantity) DESC LIMIT 1 | What are the name and phone of the customer with the most ordered product quantity? | PRAGMA foreign_keys = ON;
CREATE TABLE `Addresses` (
`address_id` INTEGER PRIMARY KEY,
`line_1_number_building` VARCHAR(80),
`city` VARCHAR(50),
`zip_postcode` VARCHAR(20),
`state_province_county` VARCHAR(50),
`country` VARCHAR(50)
);
INSERT INTO Addresses (`address_id`, `line_1_number_building`, `city`, `zip_postcode... | ('Cleo', '1-202-928-5395')
|
customers_and_products_contacts | SELECT product_type_code , product_name FROM products WHERE product_price > 1000 OR product_price < 500 | Show the product type and name for the products with price higher than 1000 or lower than 500. | PRAGMA foreign_keys = ON;
CREATE TABLE `Addresses` (
`address_id` INTEGER PRIMARY KEY,
`line_1_number_building` VARCHAR(80),
`city` VARCHAR(50),
`zip_postcode` VARCHAR(20),
`state_province_county` VARCHAR(50),
`country` VARCHAR(50)
);
INSERT INTO Addresses (`address_id`, `line_1_number_building`, `city`, `zip_postcode... | ('Hardware', 'Apple')
('Clothes', 'jcrew')
('Hardware', 'Apple')
('Hardware', 'Apple')
('Clothes', 'jcrew')
('Hardware', 'Apple')
('Hardware', 'Apple')
('Hardware', 'Sony')
('Hardware', 'Sony')
('Clothes', 'jcrew')
('Clothes', 'gucci')
('Hardware', 'Sony')
('Clothes', 'gucci')
|
dorm_1 | SELECT dorm_name FROM dorm WHERE gender = 'F' | Find the name of dorms only for female (F gender). |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('Anonymous Donor Hall',)
|
dorm_1 | SELECT dorm_name FROM dorm WHERE gender = 'F' | What are the names of the all-female dorms? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('Anonymous Donor Hall',)
|
dorm_1 | SELECT dorm_name FROM dorm WHERE student_capacity > 300 | Find the name of dorms that can accommodate more than 300 students. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('Fawlty Towers',)
('Dorm-plex 2000',)
|
dorm_1 | SELECT dorm_name FROM dorm WHERE student_capacity > 300 | What are the names of all the dorms that can accomdate more than 300 students? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('Fawlty Towers',)
('Dorm-plex 2000',)
|
dorm_1 | SELECT count(*) FROM student WHERE sex = 'F' AND age < 25 | How many female students (sex is F) whose age is below 25? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (9,)
|
dorm_1 | SELECT count(*) FROM student WHERE sex = 'F' AND age < 25 | How many girl students who are younger than 25? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (9,)
|
dorm_1 | SELECT fname FROM student WHERE age > 20 | Find the first name of students who is older than 20. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('Shiela',)
('Paul',)
('David',)
('Bruce',)
('Ian',)
('Lisa',)
('Sarah',)
|
dorm_1 | SELECT fname FROM student WHERE age > 20 | What are the first names of all students who are older than 20? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('Shiela',)
('Paul',)
('David',)
('Bruce',)
('Ian',)
('Lisa',)
('Sarah',)
|
dorm_1 | SELECT fname FROM student WHERE city_code = 'PHL' AND age BETWEEN 20 AND 25 | Find the first name of students living in city PHL whose age is between 20 and 25. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('David',)
('Sarah',)
|
dorm_1 | SELECT fname FROM student WHERE city_code = 'PHL' AND age BETWEEN 20 AND 25 | What is the first name of the students who are in age 20 to 25 and living in PHL city? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('David',)
('Sarah',)
|
dorm_1 | SELECT count(*) FROM dorm | How many dorms are there? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (7,)
|
dorm_1 | SELECT count(*) FROM dorm | How many dorms are in the database? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (7,)
|
dorm_1 | SELECT count(*) FROM dorm_amenity | Find the number of distinct amenities. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (12,)
|
dorm_1 | SELECT count(*) FROM dorm_amenity | How many diffrent dorm amenities are there? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (12,)
|
dorm_1 | SELECT sum(student_capacity) FROM dorm | Find the total capacity of all dorms. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (1380,)
|
dorm_1 | SELECT sum(student_capacity) FROM dorm | What is the total student capacity of all dorms? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (1380,)
|
dorm_1 | SELECT count(*) FROM student | How many students are there? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (34,)
|
dorm_1 | SELECT count(*) FROM student | How many students exist? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (34,)
|
dorm_1 | SELECT avg(age) , city_code FROM student GROUP BY city_code | Find the average age of all students living in the each city. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (20.0, 'ATL')
(18.5, 'BAL')
(18.0, 'BOS')
(20.0, 'CHI')
(18.0, 'DAL')
(17.0, 'DET')
(18.0, 'HKG')
(17.0, 'HOU')
(27.0, 'LON')
(18.0, 'LOS')
(18.0, 'NAR')
(20.333333333333332, 'NYC')
(17.0, 'PEK')
(19.666666666666668, 'PHL')
(19.0, 'PIT')
(20.0, 'ROC')
(21.0, 'SFO')
(21.666666666666668, 'WAS')
(22.5, 'YYZ')
|
dorm_1 | SELECT avg(age) , city_code FROM student GROUP BY city_code | What is the average age for each city and what are those cities? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (20.0, 'ATL')
(18.5, 'BAL')
(18.0, 'BOS')
(20.0, 'CHI')
(18.0, 'DAL')
(17.0, 'DET')
(18.0, 'HKG')
(17.0, 'HOU')
(27.0, 'LON')
(18.0, 'LOS')
(18.0, 'NAR')
(20.333333333333332, 'NYC')
(17.0, 'PEK')
(19.666666666666668, 'PHL')
(19.0, 'PIT')
(20.0, 'ROC')
(21.0, 'SFO')
(21.666666666666668, 'WAS')
(22.5, 'YYZ')
|
dorm_1 | SELECT avg(student_capacity) , sum(student_capacity) FROM dorm WHERE gender = 'X' | Find the average and total capacity of dorms for the students with gender X. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (227.2, 1136)
|
dorm_1 | SELECT avg(student_capacity) , sum(student_capacity) FROM dorm WHERE gender = 'X' | What is the average and total capacity for all dorms who are of gender X? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (227.2, 1136)
|
dorm_1 | SELECT count(DISTINCT dormid) FROM has_amenity | Find the number of dorms that have some amenity. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (7,)
|
dorm_1 | SELECT count(DISTINCT dormid) FROM has_amenity | How many dorms have amenities? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (7,)
|
dorm_1 | SELECT dorm_name FROM dorm WHERE dormid NOT IN (SELECT dormid FROM has_amenity) | Find the name of dorms that do not have any amenity |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | |
dorm_1 | SELECT dorm_name FROM dorm WHERE dormid NOT IN (SELECT dormid FROM has_amenity) | What are the names of all the dorms that don't have any amenities? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | |
dorm_1 | SELECT count(DISTINCT gender) FROM dorm | Find the number of distinct gender for dorms. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (3,)
|
dorm_1 | SELECT count(DISTINCT gender) FROM dorm | How many different genders are there in the dorms? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (3,)
|
dorm_1 | SELECT student_capacity , gender FROM dorm WHERE dorm_name LIKE '%Donor%' | Find the capacity and gender type of the dorm whose name has substring ‘Donor’. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (128, 'F')
|
dorm_1 | SELECT student_capacity , gender FROM dorm WHERE dorm_name LIKE '%Donor%' | What is the student capacity and type of gender for the dorm whose name as the phrase Donor in it? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (128, 'F')
|
dorm_1 | SELECT dorm_name , gender FROM dorm WHERE student_capacity > 300 OR student_capacity < 100 | Find the name and gender type of the dorms whose capacity is greater than 300 or less than 100. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('Smith Hall', 'X')
('Fawlty Towers', 'X')
('Dorm-plex 2000', 'X')
('University Hovels', 'X')
|
dorm_1 | SELECT dorm_name , gender FROM dorm WHERE student_capacity > 300 OR student_capacity < 100 | What are the names and types of the dorms that have a capacity greater than 300 or less than 100? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('Smith Hall', 'X')
('Fawlty Towers', 'X')
('Dorm-plex 2000', 'X')
('University Hovels', 'X')
|
dorm_1 | SELECT count(DISTINCT major) , count(DISTINCT city_code) FROM student | Find the numbers of different majors and cities. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (6, 19)
|
dorm_1 | SELECT count(DISTINCT major) , count(DISTINCT city_code) FROM student | How many different majors are there and how many different city codes are there for each student? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (6, 19)
|
dorm_1 | SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'TV Lounge' INTERSECT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.ameni... | Find the name of dorms which have both TV Lounge and Study Room as amenities. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('Anonymous Donor Hall',)
('Dorm-plex 2000',)
|
dorm_1 | SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'TV Lounge' INTERSECT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.ameni... | What is the name of the dorm with both a TV Lounge and Study Room listed as amenities? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('Anonymous Donor Hall',)
('Dorm-plex 2000',)
|
dorm_1 | SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'TV Lounge' EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid W... | Find the name of dorms which have TV Lounge but no Study Room as amenity. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('Fawlty Towers',)
|
dorm_1 | SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'TV Lounge' EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid W... | What is the name of each dorm that has a TV Lounge but no study rooms? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('Fawlty Towers',)
|
dorm_1 | SELECT lname FROM student WHERE sex = 'F' AND city_code = 'BAL' UNION SELECT lname FROM student WHERE sex = 'M' AND age < 20 | Find the last name of students who is either female (sex is F) and living in the city of code BAL or male (sex is M) and in age of below 20. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('Andreou',)
('Brody',)
('Epp',)
('Goldman',)
('Han',)
('Lee',)
('Nelson',)
('Norris',)
('Pang',)
('Prater',)
('Schultz',)
('Schwartz',)
('Simms',)
('Smith',)
('Tai',)
('Woods',)
|
dorm_1 | SELECT lname FROM student WHERE sex = 'F' AND city_code = 'BAL' UNION SELECT lname FROM student WHERE sex = 'M' AND age < 20 | What is the last name of every student who is either female or living in a city with the code BAL or male and under 20? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('Andreou',)
('Brody',)
('Epp',)
('Goldman',)
('Han',)
('Lee',)
('Nelson',)
('Norris',)
('Pang',)
('Prater',)
('Schultz',)
('Schwartz',)
('Simms',)
('Smith',)
('Tai',)
('Woods',)
|
dorm_1 | SELECT dorm_name FROM dorm ORDER BY student_capacity DESC LIMIT 1 | Find the name of the dorm with the largest capacity. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('Dorm-plex 2000',)
|
dorm_1 | SELECT dorm_name FROM dorm ORDER BY student_capacity DESC LIMIT 1 | What are the names of the dorm with the largest capacity? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('Dorm-plex 2000',)
|
dorm_1 | SELECT amenity_name FROM dorm_amenity ORDER BY amenity_name | List in alphabetic order all different amenities. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('4 Walls',)
('Air Conditioning',)
('Allows Pets',)
('Carpeted Rooms',)
('Ethernet Ports',)
('Heat',)
('Kitchen in Every Room',)
('Pub in Basement',)
('Roof',)
('Study Room',)
('TV Lounge',)
('Working Fireplaces',)
|
dorm_1 | SELECT amenity_name FROM dorm_amenity ORDER BY amenity_name | What are the different dorm amenity names in alphabetical order? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('4 Walls',)
('Air Conditioning',)
('Allows Pets',)
('Carpeted Rooms',)
('Ethernet Ports',)
('Heat',)
('Kitchen in Every Room',)
('Pub in Basement',)
('Roof',)
('Study Room',)
('TV Lounge',)
('Working Fireplaces',)
|
dorm_1 | SELECT city_code FROM student GROUP BY city_code ORDER BY count(*) DESC LIMIT 1 | Find the code of city where most of students are living in. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('PIT',)
|
dorm_1 | SELECT city_code FROM student GROUP BY city_code ORDER BY count(*) DESC LIMIT 1 | What is the code of the city with the most students? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('PIT',)
|
dorm_1 | SELECT fname , lname FROM student WHERE age < (SELECT avg(age) FROM student) | Find the first and last name of students whose age is younger than the average age. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('Linda', 'Smith')
('Tracy', 'Kim')
('Andy', 'Schultz')
('Lisa', 'Apap')
('Eric', 'Tai')
('Derek', 'Lee')
('Charles', 'Norris')
('Susan', 'Lee')
('Mark', 'Schwartz')
('Arthur', 'Pang')
('George', 'Andreou')
('Michael', 'Woods')
('Stacy', 'Prater')
('Mark', 'Goldman')
('Eric', 'Pang')
('Paul', 'Brody')
('Jun', 'Han')
('... |
dorm_1 | SELECT fname , lname FROM student WHERE age < (SELECT avg(age) FROM student) | What is the first and last name of all students who are younger than average? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('Linda', 'Smith')
('Tracy', 'Kim')
('Andy', 'Schultz')
('Lisa', 'Apap')
('Eric', 'Tai')
('Derek', 'Lee')
('Charles', 'Norris')
('Susan', 'Lee')
('Mark', 'Schwartz')
('Arthur', 'Pang')
('George', 'Andreou')
('Michael', 'Woods')
('Stacy', 'Prater')
('Mark', 'Goldman')
('Eric', 'Pang')
('Paul', 'Brody')
('Jun', 'Han')
('... |
dorm_1 | SELECT fname , lname FROM student WHERE city_code != 'HKG' ORDER BY age | List the first and last name of students who are not living in the city with code HKG, and sorted the results by their ages. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('Derek', 'Lee')
('Mark', 'Schwartz')
('Michael', 'Woods')
('Jun', 'Han')
('Linda', 'Smith')
('Andy', 'Schultz')
('Lisa', 'Apap')
('Charles', 'Norris')
('Arthur', 'Pang')
('Stacy', 'Prater')
('Mark', 'Goldman')
('Paul', 'Brody')
('William', 'Simms')
('Eric', 'Epp')
('Eric', 'Tai')
('George', 'Andreou')
('Dinesh', 'Kuma... |
dorm_1 | SELECT fname , lname FROM student WHERE city_code != 'HKG' ORDER BY age | What are the first and last names of all students who are not living in the city HKG and order the results by age? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('Derek', 'Lee')
('Mark', 'Schwartz')
('Michael', 'Woods')
('Jun', 'Han')
('Linda', 'Smith')
('Andy', 'Schultz')
('Lisa', 'Apap')
('Charles', 'Norris')
('Arthur', 'Pang')
('Stacy', 'Prater')
('Mark', 'Goldman')
('Paul', 'Brody')
('William', 'Simms')
('Eric', 'Epp')
('Eric', 'Tai')
('George', 'Andreou')
('Dinesh', 'Kuma... |
dorm_1 | SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T2.amenid = T1.amenid JOIN dorm AS T3 ON T2.dormid = T3.dormid WHERE T3.dorm_name = 'Anonymous Donor Hall' ORDER BY T1.amenity_name | List name of all amenities which Anonymous Donor Hall has, and sort the results in alphabetic order. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('4 Walls',)
('Air Conditioning',)
('Carpeted Rooms',)
('Ethernet Ports',)
('Heat',)
('Roof',)
('Study Room',)
('TV Lounge',)
|
dorm_1 | SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T2.amenid = T1.amenid JOIN dorm AS T3 ON T2.dormid = T3.dormid WHERE T3.dorm_name = 'Anonymous Donor Hall' ORDER BY T1.amenity_name | What are the amenities in alphabetical order that Anonymous Donor Hall has? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | ('4 Walls',)
('Air Conditioning',)
('Carpeted Rooms',)
('Ethernet Ports',)
('Heat',)
('Roof',)
('Study Room',)
('TV Lounge',)
|
dorm_1 | SELECT count(*) , sum(student_capacity) , gender FROM dorm GROUP BY gender | Find the number of dorms and total capacity for each gender. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (1, 128, 'F')
(1, 116, 'M')
(5, 1136, 'X')
|
dorm_1 | SELECT count(*) , sum(student_capacity) , gender FROM dorm GROUP BY gender | How many dorms are there and what is the total capacity for each gender? |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (1, 128, 'F')
(1, 116, 'M')
(5, 1136, 'X')
|
dorm_1 | SELECT avg(age) , max(age) , sex FROM student GROUP BY sex | Find the average and oldest age for students with different sex. |
create table Student (
StuID INTEGER PRIMARY KEY,
LName VARCHAR(12),
Fname VARCHAR(12),
Age INTEGER,
Sex VARCHAR(1),
Major INTEGER,
Advisor INTEGER,
city_code VARCHAR(3)
);
create table Dorm (
dormi... | (19.7, 26, 'F')
(19.5, 27, 'M')
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.