Dataset Viewer
db_id
stringclasses 146
values | query
stringlengths 18
577
| question
stringlengths 3
224
| schema
stringclasses 133
values |
---|---|---|---|
bike_1 | SELECT zip_code , count(*) FROM weather WHERE max_wind_Speed_mph >= 25 GROUP BY zip_code | For each zip code, return how many times max wind speed reached 25? | CREATE TABLE station (
id INTEGER PRIMARY KEY,
name TEXT,
lat NUMERIC,
long NUMERIC,
dock_count INTEGER,
city TEXT,
installation_date TEXT);
CREATE TABLE status (
station_id INTEGER,
bikes_available INTEGER,
docks_available INTEGER,
time TEXT,
FOREIGN KEY (station_id) REFERENCES station(id)
);
CREATE TABLE trip (
id INTEGER PRIMARY KEY,
duration INTEGER,
start_date TEXT,
start_station_name TEXT, -- this should be removed
start_station_id INTEGER,
end_date TEXT,
end_station_name TEXT, -- this should be removed
end_station_id INTEGER,
bike_id INTEGER,
subscription_type TEXT,
zip_code INTEGER);
CREATE TABLE weather (
date TEXT,
max_temperature_f INTEGER,
mean_temperature_f INTEGER,
min_temperature_f INTEGER,
max_dew_point_f INTEGER,
mean_dew_point_f INTEGER,
min_dew_point_f INTEGER,
max_humidity INTEGER,
mean_humidity INTEGER,
min_humidity INTEGER,
max_sea_level_pressure_inches NUMERIC,
mean_sea_level_pressure_inches NUMERIC,
min_sea_level_pressure_inches NUMERIC,
max_visibility_miles INTEGER,
mean_visibility_miles INTEGER,
min_visibility_miles INTEGER,
max_wind_Speed_mph INTEGER,
mean_wind_speed_mph INTEGER,
max_gust_speed_mph INTEGER,
precipitation_inches INTEGER,
cloud_cover INTEGER,
events TEXT,
wind_dir_degrees INTEGER,
zip_code INTEGER);
|
college_2 | SELECT min(salary) , dept_name FROM instructor GROUP BY dept_name HAVING avg(salary) > (SELECT avg(salary) FROM instructor) | Find the minimum salary for the departments whose average salary is above the average payment of all instructors. | null |
college_2 | SELECT course_id FROM SECTION WHERE semester = 'Fall' AND YEAR = 2009 EXCEPT SELECT course_id FROM SECTION WHERE semester = 'Spring' AND YEAR = 2010 | Find courses that ran in Fall 2009 but not in Spring 2010. | null |
scholar | SELECT DISTINCT t4.citedpaperid , COUNT ( t4.citedpaperid ) FROM paper AS t3 JOIN cite AS t4 ON t3.paperid = t4.citedpaperid JOIN writes AS t2 ON t2.paperid = t3.paperid JOIN author AS t1 ON t2.authorid = t1.authorid WHERE t1.authorname = "ohad shamir" GROUP BY t4.citedpaperid ORDER BY COUNT ( t4.citedpaperid ) DESC; | What is the highest cited paper by ohad shamir ? | CREATE TABLE `venue` (
`venueId` integer NOT NULL
, `venueName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`venueId`)
);
CREATE TABLE `author` (
`authorId` integer NOT NULL
, `authorName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`authorId`)
);
CREATE TABLE `dataset` (
`datasetId` integer NOT NULL
, `datasetName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`datasetId`)
);
CREATE TABLE `journal` (
`journalId` integer NOT NULL
, `journalName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`journalId`)
);
CREATE TABLE `keyphrase` (
`keyphraseId` integer NOT NULL
, `keyphraseName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`keyphraseId`)
);
CREATE TABLE `paper` (
`paperId` integer NOT NULL
, `title` varchar(300) DEFAULT NULL
, `venueId` integer DEFAULT NULL
, `year` integer DEFAULT NULL
, `numCiting` integer DEFAULT NULL
, `numCitedBy` integer DEFAULT NULL
, `journalId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`)
, FOREIGN KEY(`journalId`) REFERENCES `journal`(`journalId`)
, FOREIGN KEY(`venueId`) REFERENCES `venue`(`venueId`)
);
CREATE TABLE `cite` (
`citingPaperId` integer NOT NULL
, `citedPaperId` integer NOT NULL
, PRIMARY KEY (`citingPaperId`,`citedPaperId`)
, FOREIGN KEY(`citedpaperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`citingpaperId`) REFERENCES `paper`(`paperId`)
);
CREATE TABLE `paperDataset` (
`paperId` integer DEFAULT NULL
, `datasetId` integer DEFAULT NULL
, PRIMARY KEY (`datasetId`, `paperId`)
);
CREATE TABLE `paperKeyphrase` (
`paperId` integer DEFAULT NULL
, `keyphraseId` integer DEFAULT NULL
, PRIMARY KEY (`keyphraseId`,`paperId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`keyphraseId`) REFERENCES `keyphrase`(`keyphraseId`)
);
CREATE TABLE `writes` (
`paperId` integer DEFAULT NULL
, `authorId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`,`authorId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`authorId`) REFERENCES `author`(`authorId`)
);
|
cre_Docs_and_Epenses | SELECT count(*) FROM Documents | Count the number of documents. | CREATE TABLE Ref_Document_Types (
Document_Type_Code CHAR(15) NOT NULL,
Document_Type_Name VARCHAR(255) NOT NULL,
Document_Type_Description VARCHAR(255) NOT NULL,
PRIMARY KEY (Document_Type_Code)
);
CREATE TABLE Ref_Budget_Codes (
Budget_Type_Code CHAR(15) NOT NULL,
Budget_Type_Description VARCHAR(255) NOT NULL,
PRIMARY KEY (Budget_Type_Code)
);
CREATE TABLE Projects (
Project_ID INTEGER NOT NULL,
Project_Details VARCHAR(255),
PRIMARY KEY (Project_ID)
);
CREATE TABLE Documents (
Document_ID INTEGER NOT NULL,
Document_Type_Code CHAR(15) NOT NULL,
Project_ID INTEGER NOT NULL,
Document_Date DATETIME,
Document_Name VARCHAR(255),
Document_Description VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Document_ID),
FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code),
FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID)
);
CREATE TABLE Statements (
Statement_ID INTEGER NOT NULL,
Statement_Details VARCHAR(255),
PRIMARY KEY (Statement_ID),
FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID)
);
CREATE TABLE Documents_with_Expenses (
Document_ID INTEGER NOT NULL,
Budget_Type_Code CHAR(15) NOT NULL,
Document_Details VARCHAR(255),
PRIMARY KEY (Document_ID),
FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code),
FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID)
);
CREATE TABLE Accounts (
Account_ID INTEGER NOT NULL,
Statement_ID INTEGER NOT NULL,
Account_Details VARCHAR(255),
PRIMARY KEY (Account_ID),
FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID)
);
|
perpetrator | SELECT count(*) FROM perpetrator | How many perpetrators are there? | CREATE TABLE "perpetrator" (
"Perpetrator_ID" int,
"People_ID" int,
"Date" text,
"Year" real,
"Location" text,
"Country" text,
"Killed" int,
"Injured" int,
PRIMARY KEY ("Perpetrator_ID"),
FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID")
);
CREATE TABLE "people" (
"People_ID" int,
"Name" text,
"Height" real,
"Weight" real,
"Home Town" text,
PRIMARY KEY ("People_ID")
);
|
scholar | SELECT DISTINCT COUNT ( DISTINCT t2.paperid ) , t1.authorid FROM venue AS t3 JOIN paper AS t2 ON t3.venueid = t2.venueid JOIN writes AS t1 ON t1.paperid = t2.paperid WHERE t3.venuename = "chi" GROUP BY t1.authorid ORDER BY COUNT ( DISTINCT t2.paperid ) DESC; | who published the most at chi | CREATE TABLE `venue` (
`venueId` integer NOT NULL
, `venueName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`venueId`)
);
CREATE TABLE `author` (
`authorId` integer NOT NULL
, `authorName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`authorId`)
);
CREATE TABLE `dataset` (
`datasetId` integer NOT NULL
, `datasetName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`datasetId`)
);
CREATE TABLE `journal` (
`journalId` integer NOT NULL
, `journalName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`journalId`)
);
CREATE TABLE `keyphrase` (
`keyphraseId` integer NOT NULL
, `keyphraseName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`keyphraseId`)
);
CREATE TABLE `paper` (
`paperId` integer NOT NULL
, `title` varchar(300) DEFAULT NULL
, `venueId` integer DEFAULT NULL
, `year` integer DEFAULT NULL
, `numCiting` integer DEFAULT NULL
, `numCitedBy` integer DEFAULT NULL
, `journalId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`)
, FOREIGN KEY(`journalId`) REFERENCES `journal`(`journalId`)
, FOREIGN KEY(`venueId`) REFERENCES `venue`(`venueId`)
);
CREATE TABLE `cite` (
`citingPaperId` integer NOT NULL
, `citedPaperId` integer NOT NULL
, PRIMARY KEY (`citingPaperId`,`citedPaperId`)
, FOREIGN KEY(`citedpaperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`citingpaperId`) REFERENCES `paper`(`paperId`)
);
CREATE TABLE `paperDataset` (
`paperId` integer DEFAULT NULL
, `datasetId` integer DEFAULT NULL
, PRIMARY KEY (`datasetId`, `paperId`)
);
CREATE TABLE `paperKeyphrase` (
`paperId` integer DEFAULT NULL
, `keyphraseId` integer DEFAULT NULL
, PRIMARY KEY (`keyphraseId`,`paperId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`keyphraseId`) REFERENCES `keyphrase`(`keyphraseId`)
);
CREATE TABLE `writes` (
`paperId` integer DEFAULT NULL
, `authorId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`,`authorId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`authorId`) REFERENCES `author`(`authorId`)
);
|
flight_4 | SELECT count(*) FROM (SELECT city FROM airports GROUP BY city HAVING count(*) > 3) | What is the count of cities with more than 3 airports? | null |
bike_1 | SELECT date FROM weather WHERE mean_sea_level_pressure_inches BETWEEN 30.3 AND 31 | What are the dates in which the mean sea level pressure was between 30.3 and 31? | CREATE TABLE station (
id INTEGER PRIMARY KEY,
name TEXT,
lat NUMERIC,
long NUMERIC,
dock_count INTEGER,
city TEXT,
installation_date TEXT);
CREATE TABLE status (
station_id INTEGER,
bikes_available INTEGER,
docks_available INTEGER,
time TEXT,
FOREIGN KEY (station_id) REFERENCES station(id)
);
CREATE TABLE trip (
id INTEGER PRIMARY KEY,
duration INTEGER,
start_date TEXT,
start_station_name TEXT, -- this should be removed
start_station_id INTEGER,
end_date TEXT,
end_station_name TEXT, -- this should be removed
end_station_id INTEGER,
bike_id INTEGER,
subscription_type TEXT,
zip_code INTEGER);
CREATE TABLE weather (
date TEXT,
max_temperature_f INTEGER,
mean_temperature_f INTEGER,
min_temperature_f INTEGER,
max_dew_point_f INTEGER,
mean_dew_point_f INTEGER,
min_dew_point_f INTEGER,
max_humidity INTEGER,
mean_humidity INTEGER,
min_humidity INTEGER,
max_sea_level_pressure_inches NUMERIC,
mean_sea_level_pressure_inches NUMERIC,
min_sea_level_pressure_inches NUMERIC,
max_visibility_miles INTEGER,
mean_visibility_miles INTEGER,
min_visibility_miles INTEGER,
max_wind_Speed_mph INTEGER,
mean_wind_speed_mph INTEGER,
max_gust_speed_mph INTEGER,
precipitation_inches INTEGER,
cloud_cover INTEGER,
events TEXT,
wind_dir_degrees INTEGER,
zip_code INTEGER);
|
scholar | SELECT DISTINCT COUNT ( t1.paperid ) FROM venue AS t2 JOIN paper AS t1 ON t2.venueid = t1.venueid WHERE t2.venuename = "sigir"; | how many papers does sigir have ? | CREATE TABLE `venue` (
`venueId` integer NOT NULL
, `venueName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`venueId`)
);
CREATE TABLE `author` (
`authorId` integer NOT NULL
, `authorName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`authorId`)
);
CREATE TABLE `dataset` (
`datasetId` integer NOT NULL
, `datasetName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`datasetId`)
);
CREATE TABLE `journal` (
`journalId` integer NOT NULL
, `journalName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`journalId`)
);
CREATE TABLE `keyphrase` (
`keyphraseId` integer NOT NULL
, `keyphraseName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`keyphraseId`)
);
CREATE TABLE `paper` (
`paperId` integer NOT NULL
, `title` varchar(300) DEFAULT NULL
, `venueId` integer DEFAULT NULL
, `year` integer DEFAULT NULL
, `numCiting` integer DEFAULT NULL
, `numCitedBy` integer DEFAULT NULL
, `journalId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`)
, FOREIGN KEY(`journalId`) REFERENCES `journal`(`journalId`)
, FOREIGN KEY(`venueId`) REFERENCES `venue`(`venueId`)
);
CREATE TABLE `cite` (
`citingPaperId` integer NOT NULL
, `citedPaperId` integer NOT NULL
, PRIMARY KEY (`citingPaperId`,`citedPaperId`)
, FOREIGN KEY(`citedpaperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`citingpaperId`) REFERENCES `paper`(`paperId`)
);
CREATE TABLE `paperDataset` (
`paperId` integer DEFAULT NULL
, `datasetId` integer DEFAULT NULL
, PRIMARY KEY (`datasetId`, `paperId`)
);
CREATE TABLE `paperKeyphrase` (
`paperId` integer DEFAULT NULL
, `keyphraseId` integer DEFAULT NULL
, PRIMARY KEY (`keyphraseId`,`paperId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`keyphraseId`) REFERENCES `keyphrase`(`keyphraseId`)
);
CREATE TABLE `writes` (
`paperId` integer DEFAULT NULL
, `authorId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`,`authorId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`authorId`) REFERENCES `author`(`authorId`)
);
|
customers_card_transactions | SELECT customer_id , count(*) FROM Customers_cards GROUP BY customer_id | What are the different customer ids, and how many cards does each one hold? | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
);
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
);
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
);
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
);
|
swimming | SELECT count(*) FROM stadium | How many stadiums are there? | 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")
);
CREATE TABLE "stadium" (
"ID" int,
"name" text,
"Capacity" int,
"City" text,
"Country" text,
"Opening_year" int,
PRIMARY KEY ("ID")
);
CREATE TABLE "event" (
"ID" int,
"Name" text,
"Stadium_ID" int,
"Year" text,
PRIMARY KEY ("ID"),
FOREIGN KEY (`Stadium_ID`) REFERENCES `stadium`(`ID`)
);
CREATE TABLE "record" (
"ID" int,
"Result" text,
"Swimmer_ID" int,
"Event_ID" int,
PRIMARY KEY ("Swimmer_ID","Event_ID"),
FOREIGN KEY (`Event_ID`) REFERENCES `event`(`ID`),
FOREIGN KEY (`Swimmer_ID`) REFERENCES `swimmer`(`ID`)
);
|
academic | SELECT t5.title FROM writes AS t3 JOIN author AS t2 ON t3.aid = t2.aid JOIN publication AS t5 ON t3.pid = t5.pid JOIN writes AS t4 ON t4.pid = t5.pid JOIN author AS t1 ON t4.aid = t1.aid WHERE t2.name = "H. V. Jagadish" AND t1.name = "Divesh Srivastava" AND t5.year < 2000; | return me the papers written by " H. V. Jagadish " and " Divesh Srivastava " before 2000 . | CREATE TABLE "author" (
"aid" int,
"homepage" text,
"name" text,
"oid" int,
primary key("aid")
);
CREATE TABLE "conference" (
"cid" int,
"homepage" text,
"name" text,
primary key ("cid")
);
CREATE TABLE "domain" (
"did" int,
"name" text,
primary key ("did")
);
CREATE TABLE "domain_author" (
"aid" int,
"did" int,
primary key ("did", "aid"),
foreign key("aid") references `author`("aid"),
foreign key("did") references `domain`("did")
);
CREATE TABLE "domain_conference" (
"cid" int,
"did" int,
primary key ("did", "cid"),
foreign key("cid") references `conference`("cid"),
foreign key("did") references `domain`("did")
);
CREATE TABLE "journal" (
"homepage" text,
"jid" int,
"name" text,
primary key("jid")
);
CREATE TABLE "domain_journal" (
"did" int,
"jid" int,
primary key ("did", "jid"),
foreign key("jid") references "journal"("jid"),
foreign key("did") references "domain"("did")
);
CREATE TABLE "keyword" (
"keyword" text,
"kid" int,
primary key("kid")
);
CREATE TABLE "domain_keyword" (
"did" int,
"kid" int,
primary key ("did", "kid"),
foreign key("kid") references "keyword"("kid"),
foreign key("did") references "domain"("did")
);
CREATE TABLE "publication" (
"abstract" text,
"cid" text,
"citation_num" int,
"jid" int,
"pid" int,
"reference_num" int,
"title" text,
"year" int,
primary key("pid"),
foreign key("jid") references "journal"("jid"),
foreign key("cid") references "conference"("cid")
);
CREATE TABLE "domain_publication" (
"did" int,
"pid" int,
primary key ("did", "pid"),
foreign key("pid") references "publication"("pid"),
foreign key("did") references "domain"("did")
);
CREATE TABLE "organization" (
"continent" text,
"homepage" text,
"name" text,
"oid" int,
primary key("oid")
);
CREATE TABLE "publication_keyword" (
"pid" int,
"kid" int,
primary key ("kid", "pid"),
foreign key("pid") references "publication"("pid"),
foreign key("kid") references "keyword"("kid")
);
CREATE TABLE "writes" (
"aid" int,
"pid" int,
primary key ("aid", "pid"),
foreign key("pid") references "publication"("pid"),
foreign key("aid") references "author"("aid")
);
CREATE TABLE "cite" (
"cited" int,
"citing" int,
foreign key("cited") references "publication"("pid"),
foreign key("citing") references "publication"("pid")
);
|
farm | SELECT T1.Official_Name FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID GROUP BY T2.Host_city_ID HAVING COUNT(*) > 1 | What are the official names of cities that have hosted more than one competition? | CREATE TABLE "city" (
"City_ID" int,
"Official_Name" text,
"Status" text,
"Area_km_2" real,
"Population" real,
"Census_Ranking" text,
PRIMARY KEY ("City_ID")
);
CREATE TABLE "farm" (
"Farm_ID" int,
"Year" int,
"Total_Horses" real,
"Working_Horses" real,
"Total_Cattle" real,
"Oxen" real,
"Bulls" real,
"Cows" real,
"Pigs" real,
"Sheep_and_Goats" real,
PRIMARY KEY ("Farm_ID")
);
CREATE TABLE "farm_competition" (
"Competition_ID" int,
"Year" int,
"Theme" text,
"Host_city_ID" int,
"Hosts" text,
PRIMARY KEY ("Competition_ID"),
FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`)
);
CREATE TABLE "competition_record" (
"Competition_ID" int,
"Farm_ID" int,
"Rank" int,
PRIMARY KEY ("Competition_ID","Farm_ID"),
FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`),
FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`)
);
|
formula_1 | SELECT count(DISTINCT driverId) FROM results WHERE raceId NOT IN( SELECT raceId FROM races WHERE YEAR != 2009 ) | How many drivers did not participate in the races held in 2009? | null |
cre_Docs_and_Epenses | SELECT document_id FROM Documents_with_expenses WHERE budget_type_code = 'SF' | Give the ids of documents with expenses that have the budget code 'SF'. | CREATE TABLE Ref_Document_Types (
Document_Type_Code CHAR(15) NOT NULL,
Document_Type_Name VARCHAR(255) NOT NULL,
Document_Type_Description VARCHAR(255) NOT NULL,
PRIMARY KEY (Document_Type_Code)
);
CREATE TABLE Ref_Budget_Codes (
Budget_Type_Code CHAR(15) NOT NULL,
Budget_Type_Description VARCHAR(255) NOT NULL,
PRIMARY KEY (Budget_Type_Code)
);
CREATE TABLE Projects (
Project_ID INTEGER NOT NULL,
Project_Details VARCHAR(255),
PRIMARY KEY (Project_ID)
);
CREATE TABLE Documents (
Document_ID INTEGER NOT NULL,
Document_Type_Code CHAR(15) NOT NULL,
Project_ID INTEGER NOT NULL,
Document_Date DATETIME,
Document_Name VARCHAR(255),
Document_Description VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Document_ID),
FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code),
FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID)
);
CREATE TABLE Statements (
Statement_ID INTEGER NOT NULL,
Statement_Details VARCHAR(255),
PRIMARY KEY (Statement_ID),
FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID)
);
CREATE TABLE Documents_with_Expenses (
Document_ID INTEGER NOT NULL,
Budget_Type_Code CHAR(15) NOT NULL,
Document_Details VARCHAR(255),
PRIMARY KEY (Document_ID),
FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code),
FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID)
);
CREATE TABLE Accounts (
Account_ID INTEGER NOT NULL,
Statement_ID INTEGER NOT NULL,
Account_Details VARCHAR(255),
PRIMARY KEY (Account_ID),
FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID)
);
|
academic | SELECT t1.keyword FROM publication_keyword AS t4 JOIN keyword AS t1 ON t4.kid = t1.kid JOIN publication AS t2 ON t2.pid = t4.pid JOIN journal AS t3 ON t2.jid = t3.jid WHERE t3.name = "PVLDB" GROUP BY t1.keyword ORDER BY COUNT ( DISTINCT t2.title ) DESC LIMIT 1; | return me the keyword, which have been contained by the most number of papers in PVLDB . | CREATE TABLE "author" (
"aid" int,
"homepage" text,
"name" text,
"oid" int,
primary key("aid")
);
CREATE TABLE "conference" (
"cid" int,
"homepage" text,
"name" text,
primary key ("cid")
);
CREATE TABLE "domain" (
"did" int,
"name" text,
primary key ("did")
);
CREATE TABLE "domain_author" (
"aid" int,
"did" int,
primary key ("did", "aid"),
foreign key("aid") references `author`("aid"),
foreign key("did") references `domain`("did")
);
CREATE TABLE "domain_conference" (
"cid" int,
"did" int,
primary key ("did", "cid"),
foreign key("cid") references `conference`("cid"),
foreign key("did") references `domain`("did")
);
CREATE TABLE "journal" (
"homepage" text,
"jid" int,
"name" text,
primary key("jid")
);
CREATE TABLE "domain_journal" (
"did" int,
"jid" int,
primary key ("did", "jid"),
foreign key("jid") references "journal"("jid"),
foreign key("did") references "domain"("did")
);
CREATE TABLE "keyword" (
"keyword" text,
"kid" int,
primary key("kid")
);
CREATE TABLE "domain_keyword" (
"did" int,
"kid" int,
primary key ("did", "kid"),
foreign key("kid") references "keyword"("kid"),
foreign key("did") references "domain"("did")
);
CREATE TABLE "publication" (
"abstract" text,
"cid" text,
"citation_num" int,
"jid" int,
"pid" int,
"reference_num" int,
"title" text,
"year" int,
primary key("pid"),
foreign key("jid") references "journal"("jid"),
foreign key("cid") references "conference"("cid")
);
CREATE TABLE "domain_publication" (
"did" int,
"pid" int,
primary key ("did", "pid"),
foreign key("pid") references "publication"("pid"),
foreign key("did") references "domain"("did")
);
CREATE TABLE "organization" (
"continent" text,
"homepage" text,
"name" text,
"oid" int,
primary key("oid")
);
CREATE TABLE "publication_keyword" (
"pid" int,
"kid" int,
primary key ("kid", "pid"),
foreign key("pid") references "publication"("pid"),
foreign key("kid") references "keyword"("kid")
);
CREATE TABLE "writes" (
"aid" int,
"pid" int,
primary key ("aid", "pid"),
foreign key("pid") references "publication"("pid"),
foreign key("aid") references "author"("aid")
);
CREATE TABLE "cite" (
"cited" int,
"citing" int,
foreign key("cited") references "publication"("pid"),
foreign key("citing") references "publication"("pid")
);
|
department_store | SELECT T1.supplier_name , T1.supplier_phone FROM Suppliers AS T1 JOIN supplier_addresses AS T2 ON T1.supplier_id = T2.supplier_id JOIN addresses AS T3 ON T2.address_id = T3.address_id ORDER BY T3.address_details | List the name and phone number of all suppliers in the alphabetical order of their addresses. | CREATE TABLE `Addresses` (
`address_id` INTEGER PRIMARY KEY,
`address_details` VARCHAR(255)
);
CREATE TABLE `Staff` (
`staff_id` INTEGER PRIMARY KEY,
`staff_gender` VARCHAR(1),
`staff_name` VARCHAR(80)
);
CREATE TABLE `Suppliers` (
`supplier_id` INTEGER PRIMARY KEY,
`supplier_name` VARCHAR(80),
`supplier_phone` VARCHAR(80)
);
CREATE TABLE `Department_Store_Chain` (
`dept_store_chain_id` INTEGER PRIMARY KEY,
`dept_store_chain_name` VARCHAR(80)
);
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`payment_method_code` VARCHAR(10) NOT NULL,
`customer_code` VARCHAR(20),
`customer_name` VARCHAR(80),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(80),
`customer_email` VARCHAR(80)
);
CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`product_type_code` VARCHAR(10) NOT NULL,
`product_name` VARCHAR(80),
`product_price` DECIMAL(19,4)
);
CREATE TABLE `Supplier_Addresses` (
`supplier_id` INTEGER NOT NULL,
`address_id` INTEGER NOT NULL,
`date_from` DATETIME NOT NULL,
`date_to` DATETIME,
PRIMARY KEY (`supplier_id`, `address_id`),
FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ),
FOREIGN KEY (`supplier_id` ) REFERENCES `Suppliers`(`supplier_id` )
);
CREATE TABLE `Customer_Addresses` (
`customer_id` INTEGER NOT NULL,
`address_id` INTEGER NOT NULL,
`date_from` DATETIME NOT NULL,
`date_to` DATETIME,
PRIMARY KEY (`customer_id`, `address_id`),
FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ),
FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` )
);
CREATE TABLE `Customer_Orders` (
`order_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`order_status_code` VARCHAR(10) NOT NULL,
`order_date` DATETIME NOT NULL,
FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` )
);
CREATE TABLE `Department_Stores` (
`dept_store_id` INTEGER PRIMARY KEY,
`dept_store_chain_id` INTEGER,
`store_name` VARCHAR(80),
`store_address` VARCHAR(255),
`store_phone` VARCHAR(80),
`store_email` VARCHAR(80),
FOREIGN KEY (`dept_store_chain_id` ) REFERENCES `Department_Store_Chain`(`dept_store_chain_id` )
);
CREATE TABLE `Departments` (
`department_id` INTEGER PRIMARY KEY,
`dept_store_id` INTEGER NOT NULL,
`department_name` VARCHAR(80),
FOREIGN KEY (`dept_store_id` ) REFERENCES `Department_Stores`(`dept_store_id` )
);
CREATE TABLE `Order_Items` (
`order_item_id` INTEGER PRIMARY KEY,
`order_id` INTEGER NOT NULL,
`product_id` INTEGER NOT NULL,
FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ),
FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` )
);
CREATE TABLE `Product_Suppliers` (
`product_id` INTEGER NOT NULL,
`supplier_id` INTEGER NOT NULL,
`date_supplied_from` DATETIME NOT NULL,
`date_supplied_to` DATETIME,
`total_amount_purchased` VARCHAR(80),
`total_value_purchased` DECIMAL(19,4),
PRIMARY KEY (`product_id`, `supplier_id`),
FOREIGN KEY (`supplier_id` ) REFERENCES `Suppliers`(`supplier_id` ),
FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` )
);
CREATE TABLE `Staff_Department_Assignments` (
`staff_id` INTEGER NOT NULL,
`department_id` INTEGER NOT NULL,
`date_assigned_from` DATETIME NOT NULL,
`job_title_code` VARCHAR(10) NOT NULL,
`date_assigned_to` DATETIME,
PRIMARY KEY (`staff_id`, `department_id`),
FOREIGN KEY (`department_id` ) REFERENCES `Departments`(`department_id` ),
FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` )
);
|
scholar | SELECT DISTINCT MAX ( t3.year ) FROM writes AS t2 JOIN author AS t1 ON t2.authorid = t1.authorid JOIN paper AS t3 ON t2.paperid = t3.paperid WHERE t1.authorname = "Mary Crainie"; | When was the last time Mary Crainie published a paper ? | CREATE TABLE `venue` (
`venueId` integer NOT NULL
, `venueName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`venueId`)
);
CREATE TABLE `author` (
`authorId` integer NOT NULL
, `authorName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`authorId`)
);
CREATE TABLE `dataset` (
`datasetId` integer NOT NULL
, `datasetName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`datasetId`)
);
CREATE TABLE `journal` (
`journalId` integer NOT NULL
, `journalName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`journalId`)
);
CREATE TABLE `keyphrase` (
`keyphraseId` integer NOT NULL
, `keyphraseName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`keyphraseId`)
);
CREATE TABLE `paper` (
`paperId` integer NOT NULL
, `title` varchar(300) DEFAULT NULL
, `venueId` integer DEFAULT NULL
, `year` integer DEFAULT NULL
, `numCiting` integer DEFAULT NULL
, `numCitedBy` integer DEFAULT NULL
, `journalId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`)
, FOREIGN KEY(`journalId`) REFERENCES `journal`(`journalId`)
, FOREIGN KEY(`venueId`) REFERENCES `venue`(`venueId`)
);
CREATE TABLE `cite` (
`citingPaperId` integer NOT NULL
, `citedPaperId` integer NOT NULL
, PRIMARY KEY (`citingPaperId`,`citedPaperId`)
, FOREIGN KEY(`citedpaperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`citingpaperId`) REFERENCES `paper`(`paperId`)
);
CREATE TABLE `paperDataset` (
`paperId` integer DEFAULT NULL
, `datasetId` integer DEFAULT NULL
, PRIMARY KEY (`datasetId`, `paperId`)
);
CREATE TABLE `paperKeyphrase` (
`paperId` integer DEFAULT NULL
, `keyphraseId` integer DEFAULT NULL
, PRIMARY KEY (`keyphraseId`,`paperId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`keyphraseId`) REFERENCES `keyphrase`(`keyphraseId`)
);
CREATE TABLE `writes` (
`paperId` integer DEFAULT NULL
, `authorId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`,`authorId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`authorId`) REFERENCES `author`(`authorId`)
);
|
cre_Drama_Workshop_Groups | SELECT Status_Code FROM BOOKINGS GROUP BY Status_Code ORDER BY count(*) DESC LIMIT 1 | What is the most frequent status of bookings? | CREATE TABLE Ref_Payment_Methods (
payment_method_code CHAR(10) NOT NULL,
payment_method_description VARCHAR(80),
PRIMARY KEY (payment_method_code),
UNIQUE (payment_method_code)
);
CREATE TABLE Ref_Service_Types (
Service_Type_Code CHAR(15) NOT NULL,
Parent_Service_Type_Code CHAR(15),
Service_Type_Description VARCHAR(255),
PRIMARY KEY (Service_Type_Code),
UNIQUE (Service_Type_Code)
);
CREATE TABLE Addresses (
Address_ID VARCHAR(100) NOT NULL,
Line_1 VARCHAR(255),
Line_2 VARCHAR(255),
City_Town VARCHAR(255),
State_County VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Address_ID),
UNIQUE (Address_ID)
);
CREATE TABLE Products (
Product_ID VARCHAR(100) NOT NULL,
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
Product_Description VARCHAR(255),
Other_Product_Service_Details VARCHAR(255),
PRIMARY KEY (Product_ID),
UNIQUE (Product_ID)
);
CREATE TABLE Marketing_Regions (
Marketing_Region_Code CHAR(15) NOT NULL,
Marketing_Region_Name VARCHAR(255) NOT NULL,
Marketing_Region_Descriptrion VARCHAR(255) NOT NULL,
Other_Details VARCHAR(255),
PRIMARY KEY (Marketing_Region_Code),
UNIQUE (Marketing_Region_Code)
);
CREATE TABLE Clients (
Client_ID INTEGER NOT NULL,
Address_ID INTEGER NOT NULL,
Customer_Email_Address VARCHAR(255),
Customer_Name VARCHAR(255),
Customer_Phone VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Client_ID),
UNIQUE (Client_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID)
);
CREATE TABLE Drama_Workshop_Groups (
Workshop_Group_ID INTEGER NOT NULL,
Address_ID INTEGER NOT NULL,
Currency_Code CHAR(15) NOT NULL,
Marketing_Region_Code CHAR(15) NOT NULL,
Store_Name VARCHAR(255),
Store_Phone VARCHAR(255),
Store_Email_Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Workshop_Group_ID),
UNIQUE (Workshop_Group_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID)
);
CREATE TABLE Performers (
Performer_ID INTEGER NOT NULL,
Address_ID INTEGER NOT NULL,
Customer_Name VARCHAR(255),
Customer_Phone VARCHAR(255),
Customer_Email_Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Performer_ID),
UNIQUE (Performer_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID)
);
CREATE TABLE Customers (
Customer_ID VARCHAR(100) NOT NULL,
Address_ID INTEGER NOT NULL,
Customer_Name VARCHAR(255),
Customer_Phone VARCHAR(255),
Customer_Email_Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Customer_ID),
UNIQUE (Customer_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID)
);
CREATE TABLE Stores (
Store_ID VARCHAR(100) NOT NULL,
Address_ID INTEGER NOT NULL,
Marketing_Region_Code CHAR(15) NOT NULL,
Store_Name VARCHAR(255),
Store_Phone VARCHAR(255),
Store_Email_Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Store_ID),
UNIQUE (Store_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID),
FOREIGN KEY (Marketing_Region_Code) REFERENCES Marketing_Regions (Marketing_Region_Code)
);
CREATE TABLE Bookings (
Booking_ID INTEGER NOT NULL ,
Customer_ID INTEGER NOT NULL,
Workshop_Group_ID VARCHAR(100) NOT NULL,
Status_Code CHAR(15) NOT NULL,
Store_ID INTEGER NOT NULL,
Order_Date DATETIME NOT NULL,
Planned_Delivery_Date DATETIME NOT NULL,
Actual_Delivery_Date DATETIME NOT NULL,
Other_Order_Details VARCHAR(255),
PRIMARY KEY (Booking_ID),
UNIQUE (Booking_ID),
FOREIGN KEY (Customer_ID) REFERENCES Clients (Client_ID),
FOREIGN KEY (Workshop_Group_ID) REFERENCES Drama_Workshop_Groups (Workshop_Group_ID)
);
CREATE TABLE Performers_in_Bookings (
Order_ID INTEGER NOT NULL,
Performer_ID INTEGER NOT NULL,
PRIMARY KEY (Order_ID, Performer_ID),
FOREIGN KEY (Performer_ID) REFERENCES Performers (Performer_ID),
FOREIGN KEY (Order_ID) REFERENCES Bookings (Booking_ID)
);
CREATE TABLE Customer_Orders (
Order_ID INTEGER NOT NULL ,
Customer_ID INTEGER NOT NULL,
Store_ID INTEGER NOT NULL,
Order_Date DATETIME NOT NULL,
Planned_Delivery_Date DATETIME NOT NULL,
Actual_Delivery_Date DATETIME NOT NULL,
Other_Order_Details VARCHAR(255),
PRIMARY KEY (Order_ID),
UNIQUE (Order_ID),
FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID),
FOREIGN KEY (Store_ID) REFERENCES Stores (Store_ID)
);
CREATE TABLE Order_Items (
Order_Item_ID INTEGER NOT NULL ,
Order_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
Order_Quantity VARCHAR(288),
Other_Item_Details VARCHAR(255),
PRIMARY KEY (Order_Item_ID),
FOREIGN KEY (Order_ID) REFERENCES Customer_Orders (Order_ID),
FOREIGN KEY (Product_ID) REFERENCES Products (Product_ID)
);
CREATE TABLE Invoices (
Invoice_ID INTEGER NOT NULL,
Order_ID INTEGER NOT NULL,
payment_method_code CHAR(15),
Product_ID INTEGER NOT NULL,
Order_Quantity VARCHAR(288),
Other_Item_Details VARCHAR(255),
Order_Item_ID INTEGER NOT NULL,
PRIMARY KEY (Invoice_ID),
FOREIGN KEY (Order_ID) REFERENCES Customer_Orders (Order_ID),
FOREIGN KEY (Order_ID) REFERENCES Bookings (Booking_ID),
FOREIGN KEY (payment_method_code) REFERENCES Ref_Payment_Methods (payment_method_code)
);
CREATE TABLE Services (
Service_ID INTEGER NOT NULL,
Service_Type_Code CHAR(15),
Workshop_Group_ID INTEGER NOT NULL,
Product_Description VARCHAR(255),
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
Other_Product_Service_Details VARCHAR(255),
PRIMARY KEY (Service_ID),
UNIQUE (Service_ID),
FOREIGN KEY (Workshop_Group_ID) REFERENCES Drama_Workshop_Groups (Workshop_Group_ID),
FOREIGN KEY (Service_Type_Code) REFERENCES Ref_Service_Types (Service_Type_Code)
);
CREATE TABLE Bookings_Services (
Order_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
PRIMARY KEY (Order_ID, Product_ID),
FOREIGN KEY (Order_ID) REFERENCES Bookings (Booking_ID),
FOREIGN KEY (Product_ID) REFERENCES Services (Service_ID)
);
CREATE TABLE Invoice_Items (
Invoice_Item_ID INTEGER NOT NULL ,
Invoice_ID INTEGER NOT NULL,
Order_ID INTEGER NOT NULL,
Order_Item_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
Order_Quantity INTEGER,
Other_Item_Details VARCHAR(255),
PRIMARY KEY (Invoice_Item_ID),
FOREIGN KEY (Order_Item_ID) REFERENCES Order_Items (Order_Item_ID),
FOREIGN KEY (Invoice_ID) REFERENCES Invoices (Invoice_ID),
FOREIGN KEY (Order_ID, Product_ID) REFERENCES Bookings_Services (Order_ID,Product_ID)
);
|
insurance_and_eClaims | SELECT policy_type_code FROM policies GROUP BY policy_type_code ORDER BY count(*) DESC LIMIT 1 | Find the type code of the most frequently used policy. | CREATE TABLE Customers (
Customer_ID INTEGER NOT NULL,
Customer_Details VARCHAR(255) NOT NULL,
PRIMARY KEY (Customer_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Staff_Details VARCHAR(255) NOT NULL,
PRIMARY KEY (Staff_ID)
);
CREATE TABLE Policies (
Policy_ID INTEGER NOT NULL,
Customer_ID INTEGER NOT NULL,
Policy_Type_Code CHAR(15) NOT NULL,
Start_Date DATETIME,
End_Date DATETIME,
PRIMARY KEY (Policy_ID),
FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID)
);
CREATE TABLE Claim_Headers (
Claim_Header_ID INTEGER NOT NULL,
Claim_Status_Code CHAR(15) NOT NULL,
Claim_Type_Code CHAR(15) NOT NULL,
Policy_ID INTEGER NOT NULL,
Date_of_Claim DATETIME,
Date_of_Settlement DATETIME,
Amount_Claimed DECIMAL(20,4),
Amount_Piad DECIMAL(20,4),
PRIMARY KEY (Claim_Header_ID),
FOREIGN KEY (Policy_ID) REFERENCES Policies (Policy_ID)
);
CREATE TABLE Claims_Documents (
Claim_ID INTEGER NOT NULL,
Document_Type_Code CHAR(15) NOT NULL,
Created_by_Staff_ID INTEGER,
Created_Date INTEGER,
PRIMARY KEY (Claim_ID, Document_Type_Code),
FOREIGN KEY (Claim_ID) REFERENCES Claim_Headers (Claim_Header_ID),
FOREIGN KEY (Created_by_Staff_ID) REFERENCES Staff (Staff_ID)
);
CREATE TABLE Claims_Processing_Stages (
Claim_Stage_ID INTEGER NOT NULL,
Next_Claim_Stage_ID INTEGER,
Claim_Status_Name VARCHAR(255) NOT NULL,
Claim_Status_Description VARCHAR(255) NOT NULL,
PRIMARY KEY (Claim_Stage_ID)
);
CREATE TABLE Claims_Processing (
Claim_Processing_ID INTEGER NOT NULL,
Claim_ID INTEGER NOT NULL,
Claim_Outcome_Code CHAR(15) NOT NULL,
Claim_Stage_ID INTEGER NOT NULL,
Staff_ID INTEGER,
PRIMARY KEY (Claim_Processing_ID),
FOREIGN KEY (Claim_ID) REFERENCES Claim_Headers (Claim_Header_ID),
FOREIGN KEY (Staff_ID) REFERENCES Staff (Staff_ID)
);
|
scholar | SELECT DISTINCT t1.paperid FROM venue AS t2 JOIN paper AS t1 ON t2.venueid = t1.venueid WHERE t1.year = 2015 AND t2.venuename = "pldi"; | papers in pldi 2015 | CREATE TABLE `venue` (
`venueId` integer NOT NULL
, `venueName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`venueId`)
);
CREATE TABLE `author` (
`authorId` integer NOT NULL
, `authorName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`authorId`)
);
CREATE TABLE `dataset` (
`datasetId` integer NOT NULL
, `datasetName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`datasetId`)
);
CREATE TABLE `journal` (
`journalId` integer NOT NULL
, `journalName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`journalId`)
);
CREATE TABLE `keyphrase` (
`keyphraseId` integer NOT NULL
, `keyphraseName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`keyphraseId`)
);
CREATE TABLE `paper` (
`paperId` integer NOT NULL
, `title` varchar(300) DEFAULT NULL
, `venueId` integer DEFAULT NULL
, `year` integer DEFAULT NULL
, `numCiting` integer DEFAULT NULL
, `numCitedBy` integer DEFAULT NULL
, `journalId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`)
, FOREIGN KEY(`journalId`) REFERENCES `journal`(`journalId`)
, FOREIGN KEY(`venueId`) REFERENCES `venue`(`venueId`)
);
CREATE TABLE `cite` (
`citingPaperId` integer NOT NULL
, `citedPaperId` integer NOT NULL
, PRIMARY KEY (`citingPaperId`,`citedPaperId`)
, FOREIGN KEY(`citedpaperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`citingpaperId`) REFERENCES `paper`(`paperId`)
);
CREATE TABLE `paperDataset` (
`paperId` integer DEFAULT NULL
, `datasetId` integer DEFAULT NULL
, PRIMARY KEY (`datasetId`, `paperId`)
);
CREATE TABLE `paperKeyphrase` (
`paperId` integer DEFAULT NULL
, `keyphraseId` integer DEFAULT NULL
, PRIMARY KEY (`keyphraseId`,`paperId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`keyphraseId`) REFERENCES `keyphrase`(`keyphraseId`)
);
CREATE TABLE `writes` (
`paperId` integer DEFAULT NULL
, `authorId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`,`authorId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`authorId`) REFERENCES `author`(`authorId`)
);
|
scholar | SELECT DISTINCT t1.authorid , t3.paperid FROM paperkeyphrase AS t2 JOIN keyphrase AS t5 ON t2.keyphraseid = t5.keyphraseid JOIN paper AS t3 ON t3.paperid = t2.paperid JOIN writes AS t4 ON t4.paperid = t3.paperid JOIN author AS t1 ON t4.authorid = t1.authorid WHERE t1.authorname = "brian curless" AND t5.keyphrasename = "convolution"; | What papers has brian curless written about convolution ? | CREATE TABLE `venue` (
`venueId` integer NOT NULL
, `venueName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`venueId`)
);
CREATE TABLE `author` (
`authorId` integer NOT NULL
, `authorName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`authorId`)
);
CREATE TABLE `dataset` (
`datasetId` integer NOT NULL
, `datasetName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`datasetId`)
);
CREATE TABLE `journal` (
`journalId` integer NOT NULL
, `journalName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`journalId`)
);
CREATE TABLE `keyphrase` (
`keyphraseId` integer NOT NULL
, `keyphraseName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`keyphraseId`)
);
CREATE TABLE `paper` (
`paperId` integer NOT NULL
, `title` varchar(300) DEFAULT NULL
, `venueId` integer DEFAULT NULL
, `year` integer DEFAULT NULL
, `numCiting` integer DEFAULT NULL
, `numCitedBy` integer DEFAULT NULL
, `journalId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`)
, FOREIGN KEY(`journalId`) REFERENCES `journal`(`journalId`)
, FOREIGN KEY(`venueId`) REFERENCES `venue`(`venueId`)
);
CREATE TABLE `cite` (
`citingPaperId` integer NOT NULL
, `citedPaperId` integer NOT NULL
, PRIMARY KEY (`citingPaperId`,`citedPaperId`)
, FOREIGN KEY(`citedpaperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`citingpaperId`) REFERENCES `paper`(`paperId`)
);
CREATE TABLE `paperDataset` (
`paperId` integer DEFAULT NULL
, `datasetId` integer DEFAULT NULL
, PRIMARY KEY (`datasetId`, `paperId`)
);
CREATE TABLE `paperKeyphrase` (
`paperId` integer DEFAULT NULL
, `keyphraseId` integer DEFAULT NULL
, PRIMARY KEY (`keyphraseId`,`paperId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`keyphraseId`) REFERENCES `keyphrase`(`keyphraseId`)
);
CREATE TABLE `writes` (
`paperId` integer DEFAULT NULL
, `authorId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`,`authorId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`authorId`) REFERENCES `author`(`authorId`)
);
|
manufactory_1 | SELECT name FROM manufacturers EXCEPT SELECT T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code WHERE T1.name = 'DVD drive' | Find the name of companies that do not make DVD drive. | CREATE TABLE Manufacturers (
Code INTEGER,
Name VARCHAR(255) NOT NULL,
Headquarter VARCHAR(255) NOT NULL,
Founder VARCHAR(255) NOT NULL,
Revenue REAL,
PRIMARY KEY (Code)
);
CREATE TABLE Products (
Code INTEGER,
Name VARCHAR(255) NOT NULL ,
Price DECIMAL NOT NULL ,
Manufacturer INTEGER NOT NULL,
PRIMARY KEY (Code),
FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code)
);
|
college_2 | SELECT count(DISTINCT dept_name) FROM course | Count the number of departments which offer courses. | null |
game_injury | SELECT T1.id , T1.score , T1.date FROM game AS T1 JOIN injury_accident AS T2 ON T2.game_id = T1.id GROUP BY T1.id HAVING count(*) >= 2 | What are the ids, scores, and dates of the games which caused at least two injury accidents? | CREATE TABLE "stadium" (
"id" int,
"name" text,
"Home_Games" int,
"Average_Attendance" real,
"Total_Attendance" real,
"Capacity_Percentage" real,
primary key ("id")
);
CREATE TABLE "game" (
"stadium_id" int,
"id" int,
"Season" int,
"Date" text,
"Home_team" text,
"Away_team" text,
"Score" text,
"Competition" text,
primary key ("id"),
foreign key ("stadium_id") references `stadium`("id")
);
CREATE TABLE "injury_accident" (
"game_id" int,
"id" int,
"Player" text,
"Injury" text,
"Number_of_matches" text,
"Source" text,
primary key ("id"),
foreign key ("game_id") references `game`("id")
);
|
performance_attendance | SELECT LOCATION , COUNT(*) FROM performance GROUP BY LOCATION | Show different locations and the number of performances at each location. | CREATE TABLE "member" (
"Member_ID" text,
"Name" text,
"Nationality" text,
"Role" text,
PRIMARY KEY ("Member_ID")
);
CREATE TABLE "performance" (
"Performance_ID" real,
"Date" text,
"Host" text,
"Location" text,
"Attendance" int,
PRIMARY KEY ("Performance_ID")
);
CREATE TABLE "member_attendance" (
"Member_ID" int,
"Performance_ID" int,
"Num_of_Pieces" int,
PRIMARY KEY ("Member_ID","Performance_ID"),
FOREIGN KEY ("Member_ID") REFERENCES `member`("Member_ID"),
FOREIGN KEY ("Performance_ID") REFERENCES `performance`("Performance_ID")
);
|
game_1 | SELECT StuID FROM Student WHERE sex = 'F' INTERSECT SELECT StuID FROM Sportsinfo WHERE sportname = "Football" | What are the ids of all female students who play football? | 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 Video_Games (
GameID INTEGER PRIMARY KEY,
GName VARCHAR(40),
GType VARCHAR(40)
);
create table Plays_Games (
StuID INTEGER,
GameID INTEGER,
Hours_Played INTEGER,
FOREIGN KEY(GameID) REFERENCES Video_Games(GameID),
FOREIGN KEY(StuID) REFERENCES Student(StuID)
);
create table SportsInfo (
StuID INTEGER,
SportName VARCHAR(32),
HoursPerWeek INTEGER,
GamesPlayed INTEGER,
OnScholarship VARCHAR(1),
FOREIGN KEY(StuID) REFERENCES Student(StuID)
);
|
chinook_1 | SELECT AVG(T2.UnitPrice) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Rock" | What is the average unit price of rock tracks? | null |
geo | SELECT state_name FROM state WHERE population = ( SELECT MAX ( population ) FROM state ); | what state is the largest in population | CREATE TABLE `state` (
`state_name` text
, `population` integer DEFAULT NULL
, `area` double DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `capital` text
, `density` double DEFAULT NULL
, PRIMARY KEY (`state_name`)
);
CREATE TABLE `city` (
`city_name` text
, `population` integer DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `state_name` text
, PRIMARY KEY (`city_name`,`state_name`)
, FOREIGN KEY(`state_name`) REFERENCES `state`(`state_name`)
);
CREATE TABLE `border_info` (
`state_name` text
, `border` text
, PRIMARY KEY (`border`,`state_name`)
, FOREIGN KEY(`state_name`) REFERENCES `state`(`state_name`)
, FOREIGN KEY(`border`) REFERENCES `state`(`state_name`)
);
CREATE TABLE `highlow` (
`state_name` text
, `highest_elevation` text
, `lowest_point` text
, `highest_point` text
, `lowest_elevation` text
, PRIMARY KEY (`state_name`)
, FOREIGN KEY(`state_name`) REFERENCES `state`(`state_name`)
);
CREATE TABLE `lake` (
`lake_name` text
, `area` double DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `state_name` text
);
CREATE TABLE `mountain` (
`mountain_name` text
, `mountain_altitude` integer DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `state_name` text
, PRIMARY KEY (`mountain_name`, `state_name`)
, FOREIGN KEY(`state_name`) REFERENCES `state`(`state_name`)
);
CREATE TABLE `river` (
`river_name` text
, `length` integer DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `traverse` text
, PRIMARY KEY (`river_name`)
, FOREIGN KEY(`traverse`) REFERENCES `state`(`state_name`)
); |
match_season | SELECT POSITION , COUNT(*) FROM match_season GROUP BY POSITION | Show the position of players and the corresponding number of players. | CREATE TABLE "country" (
"Country_id" int,
"Country_name" text,
"Capital" text,
"Official_native_language" text,
PRIMARY KEY ("Country_id")
);
CREATE TABLE `team` (
`Team_id` int,
`Name` text,
PRIMARY KEY (`Team_id`)
) ;
CREATE TABLE "match_season" (
"Season" real,
"Player" text,
"Position" text,
"Country" int,
"Team" int,
"Draft_Pick_Number" int,
"Draft_Class" text,
"College" text,
PRIMARY KEY ("Season"),
FOREIGN KEY (`Country`) REFERENCES `country`(`Country_id`),
FOREIGN KEY (`Team`) REFERENCES `team`(`Team_id`)
);
CREATE TABLE "player" (
"Player_ID" int,
"Player" text,
"Years_Played" text,
"Total_WL" text,
"Singles_WL" text,
"Doubles_WL" text,
"Team" int,
PRIMARY KEY ("Player_ID"),
FOREIGN KEY (`Team`) REFERENCES `team`(`Team_id`)
);
|
candidate_poll | SELECT name FROM people ORDER BY date_of_birth | What are the names of all people, ordered by their date of birth? | CREATE TABLE "candidate" (
"Candidate_ID" int,
"People_ID" int,
"Poll_Source" text,
"Date" text,
"Support_rate" real,
"Consider_rate" real,
"Oppose_rate" real,
"Unsure_rate" real,
PRIMARY KEY ("Candidate_ID"),
FOREIGN KEY ("People_ID") REFERENCES "people"("People_ID")
);
CREATE TABLE "people" (
"People_ID" int,
"Sex" text,
"Name" text,
"Date_of_Birth" text,
"Height" real,
"Weight" real,
PRIMARY KEY ("People_ID")
);
|
sakila_1 | SELECT count(*) FROM inventory WHERE store_id = 1 | Count the number of items store 1 has in stock. | CREATE TABLE actor (
actor_id SMALLINT UNSIGNED NOT NULL,
first_name VARCHAR(45) NOT NULL,
last_name VARCHAR(45) NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (actor_id)
);
CREATE TABLE address (
address_id SMALLINT UNSIGNED NOT NULL,
address VARCHAR(50) NOT NULL,
address2 VARCHAR(50) DEFAULT NULL,
district VARCHAR(20) NOT NULL,
city_id SMALLINT UNSIGNED NOT NULL,
postal_code VARCHAR(10) DEFAULT NULL,
phone VARCHAR(20) NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (address_id),
FOREIGN KEY (city_id) REFERENCES city (city_id)
);
CREATE TABLE category (
category_id TINYINT UNSIGNED NOT NULL,
name VARCHAR(25) NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (category_id)
);
CREATE TABLE city (
city_id SMALLINT UNSIGNED NOT NULL,
city VARCHAR(50) NOT NULL,
country_id SMALLINT UNSIGNED NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (city_id),
FOREIGN KEY (country_id) REFERENCES country (country_id)
);
CREATE TABLE country (
country_id SMALLINT UNSIGNED NOT NULL,
country VARCHAR(50) NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (country_id)
);
CREATE TABLE customer (
customer_id SMALLINT UNSIGNED NOT NULL,
store_id TINYINT UNSIGNED NOT NULL,
first_name VARCHAR(45) NOT NULL,
last_name VARCHAR(45) NOT NULL,
email VARCHAR(50) DEFAULT NULL,
address_id SMALLINT UNSIGNED NOT NULL,
active BOOLEAN NOT NULL DEFAULT TRUE,
create_date DATETIME NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (customer_id),
FOREIGN KEY (address_id) REFERENCES address (address_id),
FOREIGN KEY (store_id) REFERENCES store (store_id)
);
CREATE TABLE film (
film_id SMALLINT UNSIGNED NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT DEFAULT NULL,
release_year YEAR DEFAULT NULL,
language_id TINYINT UNSIGNED NOT NULL,
original_language_id TINYINT UNSIGNED DEFAULT NULL,
rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3,
rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99,
length SMALLINT UNSIGNED DEFAULT NULL,
replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99,
rating DEFAULT 'G',
special_features DEFAULT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (film_id),
FOREIGN KEY (language_id) REFERENCES language (language_id),
FOREIGN KEY (original_language_id) REFERENCES language (language_id)
);
CREATE TABLE film_actor (
actor_id SMALLINT UNSIGNED NOT NULL,
film_id SMALLINT UNSIGNED NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (actor_id,film_id),
FOREIGN KEY (actor_id) REFERENCES actor (actor_id),
FOREIGN KEY (film_id) REFERENCES film (film_id)
);
CREATE TABLE film_category (
film_id SMALLINT UNSIGNED NOT NULL,
category_id TINYINT UNSIGNED NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (film_id, category_id),
FOREIGN KEY (film_id) REFERENCES film (film_id),
FOREIGN KEY (category_id) REFERENCES category (category_id)
);
CREATE TABLE film_text (
film_id SMALLINT NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT,
PRIMARY KEY (film_id)
);
CREATE TABLE inventory (
inventory_id MEDIUMINT UNSIGNED NOT NULL,
film_id SMALLINT UNSIGNED NOT NULL,
store_id TINYINT UNSIGNED NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (inventory_id),
FOREIGN KEY (store_id) REFERENCES store (store_id),
FOREIGN KEY (film_id) REFERENCES film (film_id)
);
CREATE TABLE language (
language_id TINYINT UNSIGNED NOT NULL,
name CHAR(20) NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (language_id)
);
CREATE TABLE payment (
payment_id SMALLINT UNSIGNED NOT NULL,
customer_id SMALLINT UNSIGNED NOT NULL,
staff_id TINYINT UNSIGNED NOT NULL,
rental_id INT DEFAULT NULL,
amount DECIMAL(5,2) NOT NULL,
payment_date DATETIME NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (payment_id),
FOREIGN KEY (rental_id) REFERENCES rental (rental_id),
FOREIGN KEY (customer_id) REFERENCES customer (customer_id),
FOREIGN KEY (staff_id) REFERENCES staff (staff_id)
);
CREATE TABLE rental (
rental_id INT NOT NULL,
rental_date DATETIME NOT NULL,
inventory_id MEDIUMINT UNSIGNED NOT NULL,
customer_id SMALLINT UNSIGNED NOT NULL,
return_date DATETIME DEFAULT NULL,
staff_id TINYINT UNSIGNED NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (rental_id),
FOREIGN KEY (staff_id) REFERENCES staff (staff_id),
FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id),
FOREIGN KEY (customer_id) REFERENCES customer (customer_id)
);
CREATE TABLE staff (
staff_id TINYINT UNSIGNED NOT NULL,
first_name VARCHAR(45) NOT NULL,
last_name VARCHAR(45) NOT NULL,
address_id SMALLINT UNSIGNED NOT NULL,
picture BLOB DEFAULT NULL,
email VARCHAR(50) DEFAULT NULL,
store_id TINYINT UNSIGNED NOT NULL,
active BOOLEAN NOT NULL DEFAULT TRUE,
username VARCHAR(16) NOT NULL,
password VARCHAR(40) DEFAULT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (staff_id),
--FOREIGN KEY (store_id) REFERENCES store (store_id),
FOREIGN KEY (address_id) REFERENCES address (address_id)
);
CREATE TABLE store (
store_id TINYINT UNSIGNED NOT NULL,
manager_staff_id TINYINT UNSIGNED NOT NULL,
address_id SMALLINT UNSIGNED NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (store_id),
FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id),
FOREIGN KEY (address_id) REFERENCES address (address_id)
);
|
student_assessment | SELECT course_name FROM courses ORDER BY course_name | List the names of courses in alphabetical order? | CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
line_1 VARCHAR(80),
line_2 VARCHAR(80),
city VARCHAR(50),
zip_postcode CHAR(20),
state_province_county VARCHAR(50),
country VARCHAR(50),
PRIMARY KEY (address_id)
);
CREATE TABLE People (
person_id INTEGER NOT NULL,
first_name VARCHAR(255),
middle_name VARCHAR(255),
last_name VARCHAR(255),
cell_mobile_number VARCHAR(40),
email_address VARCHAR(40),
login_name VARCHAR(40),
password VARCHAR(40),
PRIMARY KEY (person_id)
);
CREATE TABLE Students (
student_id INTEGER NOT NULL,
student_details VARCHAR(255),
PRIMARY KEY (student_id),
FOREIGN KEY (student_id) REFERENCES People (person_id)
);
CREATE TABLE Courses (
course_id VARCHAR(100) NOT NULL,
course_name VARCHAR(120),
course_description VARCHAR(255),
other_details VARCHAR(255),
PRIMARY KEY (course_id)
);
CREATE TABLE People_Addresses (
person_address_id INTEGER NOT NULL,
person_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
date_from DATETIME,
date_to DATETIME,
PRIMARY KEY (person_address_id),
FOREIGN KEY (person_id) REFERENCES People (person_id),
FOREIGN KEY (address_id) REFERENCES Addresses (address_id)
);
CREATE TABLE Student_Course_Registrations (
student_id INTEGER NOT NULL,
course_id INTEGER NOT NULL,
registration_date DATETIME NOT NULL,
PRIMARY KEY (student_id, course_id),
FOREIGN KEY (student_id) REFERENCES Students (student_id),
FOREIGN KEY (course_id) REFERENCES Courses (course_id)
);
CREATE TABLE Student_Course_Attendance (
student_id INTEGER NOT NULL,
course_id INTEGER NOT NULL,
date_of_attendance DATETIME NOT NULL,
PRIMARY KEY (student_id, course_id),
FOREIGN KEY (student_id, course_id) REFERENCES Student_Course_Registrations (student_id,course_id)
);
CREATE TABLE Candidates (
candidate_id INTEGER NOT NULL ,
candidate_details VARCHAR(255),
PRIMARY KEY (candidate_id),
FOREIGN KEY (candidate_id) REFERENCES People (person_id)
);
CREATE TABLE Candidate_Assessments (
candidate_id INTEGER NOT NULL,
qualification CHAR(15) NOT NULL,
assessment_date DATETIME NOT NULL,
asessment_outcome_code CHAR(15) NOT NULL,
PRIMARY KEY (candidate_id, qualification),
FOREIGN KEY (candidate_id) REFERENCES Candidates (candidate_id)
);
|
e_government | SELECT payment_method_code FROM parties GROUP BY payment_method_code HAVING count(*) > 3 | Find the payment method code used by more than 3 parties. | CREATE TABLE `Addresses` (
`address_id` INTEGER PRIMARY KEY,
`line_1_number_building` VARCHAR(80),
`town_city` VARCHAR(50),
`zip_postcode` VARCHAR(20),
`state_province_county` VARCHAR(50),
`country` VARCHAR(50)
);
CREATE TABLE `Services` (
`service_id` INTEGER PRIMARY KEY,
`service_type_code` VARCHAR(15) NOT NULL,
`service_name` VARCHAR(80),
`service_descriptio` VARCHAR(255)
);
CREATE TABLE `Forms` (
`form_id` INTEGER PRIMARY KEY,
`form_type_code` VARCHAR(15) NOT NULL,
`service_id` INTEGER,
`form_number` VARCHAR(50),
`form_name` VARCHAR(80),
`form_description` VARCHAR(255),
FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` )
);
CREATE TABLE `Individuals` (
`individual_id` INTEGER PRIMARY KEY,
`individual_first_name` VARCHAR(80),
`individual_middle_name` VARCHAR(80),
`inidividual_phone` VARCHAR(80),
`individual_email` VARCHAR(80),
`individual_address` VARCHAR(255),
`individual_last_name` VARCHAR(80)
);
CREATE TABLE `Organizations` (
`organization_id` INTEGER PRIMARY KEY,
`date_formed` DATETIME,
`organization_name` VARCHAR(255),
`uk_vat_number` VARCHAR(20)
);
CREATE TABLE `Parties` (
`party_id` INTEGER PRIMARY KEY,
`payment_method_code` VARCHAR(15) NOT NULL,
`party_phone` VARCHAR(80),
`party_email` VARCHAR(80)
);
CREATE TABLE `Organization_Contact_Individuals` (
`individual_id` INTEGER NOT NULL,
`organization_id` INTEGER NOT NULL,
`date_contact_from` DATETIME NOT NULL,
`date_contact_to` DATETIME,
PRIMARY KEY (`individual_id`,`organization_id` ),
FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ),
FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` )
);
CREATE TABLE `Party_Addresses` (
`party_id` INTEGER NOT NULL,
`address_id` INTEGER NOT NULL,
`date_address_from` DATETIME NOT NULL,
`address_type_code` VARCHAR(15) NOT NULL,
`date_address_to` DATETIME,
PRIMARY KEY (`party_id`, `address_id`),
FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ),
FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` )
);
CREATE TABLE `Party_Forms` (
`party_id` INTEGER NOT NULL,
`form_id` INTEGER NOT NULL,
`date_completion_started` DATETIME NOT NULL,
`form_status_code` VARCHAR(15) NOT NULL,
`date_fully_completed` DATETIME,
PRIMARY KEY (`party_id`, `form_id`),
FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ),
FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` )
);
CREATE TABLE `Party_Services` (
`booking_id` INTEGER NOT NULL ,
`customer_id` INTEGER NOT NULL,
`service_id` INTEGER NOT NULL,
`service_datetime` DATETIME NOT NULL,
`booking_made_date` DATETIME,
FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ),
FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` )
);
|
movie_1 | SELECT name FROM Reviewer UNION SELECT title FROM Movie | What are the names of all the reviewers and movie names? | create table Movie(
mID int primary key,
title text,
year int,
director text
);
create table Reviewer(
rID int primary key,
name text);
create table Rating(
rID int,
mID int,
stars int,
ratingDate date,
FOREIGN KEY (mID) references Movie(mID),
FOREIGN KEY (rID) references Reviewer(rID)
);
|
geo | SELECT border FROM border_info WHERE state_name = "kentucky"; | what states neighbor kentucky | CREATE TABLE `state` (
`state_name` text
, `population` integer DEFAULT NULL
, `area` double DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `capital` text
, `density` double DEFAULT NULL
, PRIMARY KEY (`state_name`)
);
CREATE TABLE `city` (
`city_name` text
, `population` integer DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `state_name` text
, PRIMARY KEY (`city_name`,`state_name`)
, FOREIGN KEY(`state_name`) REFERENCES `state`(`state_name`)
);
CREATE TABLE `border_info` (
`state_name` text
, `border` text
, PRIMARY KEY (`border`,`state_name`)
, FOREIGN KEY(`state_name`) REFERENCES `state`(`state_name`)
, FOREIGN KEY(`border`) REFERENCES `state`(`state_name`)
);
CREATE TABLE `highlow` (
`state_name` text
, `highest_elevation` text
, `lowest_point` text
, `highest_point` text
, `lowest_elevation` text
, PRIMARY KEY (`state_name`)
, FOREIGN KEY(`state_name`) REFERENCES `state`(`state_name`)
);
CREATE TABLE `lake` (
`lake_name` text
, `area` double DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `state_name` text
);
CREATE TABLE `mountain` (
`mountain_name` text
, `mountain_altitude` integer DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `state_name` text
, PRIMARY KEY (`mountain_name`, `state_name`)
, FOREIGN KEY(`state_name`) REFERENCES `state`(`state_name`)
);
CREATE TABLE `river` (
`river_name` text
, `length` integer DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `traverse` text
, PRIMARY KEY (`river_name`)
, FOREIGN KEY(`traverse`) REFERENCES `state`(`state_name`)
); |
network_2 | SELECT count(T2.friend) FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T1.name = 'Dan' | How many friends does Dan have? | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
);
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
);
|
party_host | SELECT T3.Location , T2.Name FROM party_host AS T1 JOIN HOST AS T2 ON T1.Host_ID = T2.Host_ID JOIN party AS T3 ON T1.Party_ID = T3.Party_ID ORDER BY T2.Age | Show the locations of parties and the names of the party hosts in ascending order of the age of the host. | CREATE TABLE "party" (
"Party_ID" int,
"Party_Theme" text,
"Location" text,
"First_year" text,
"Last_year" text,
"Number_of_hosts" int,
PRIMARY KEY ("Party_ID")
);
CREATE TABLE "host" (
"Host_ID" int,
"Name" text,
"Nationality" text,
"Age" text,
PRIMARY KEY ("Host_ID")
);
CREATE TABLE "party_host" (
"Party_ID" int,
"Host_ID" int,
"Is_Main_in_Charge" bool,
PRIMARY KEY ("Party_ID","Host_ID"),
FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"),
FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID")
);
|
college_2 | SELECT name FROM instructor WHERE dept_name = 'Comp. Sci.' AND salary > 80000 | What are the names of the instructors in the Comp. Sci. department who earn more than 80000? | null |
scholar | SELECT DISTINCT t3.paperid FROM paperkeyphrase AS t2 JOIN keyphrase AS t1 ON t2.keyphraseid = t1.keyphraseid JOIN paper AS t3 ON t3.paperid = t2.paperid WHERE t1.keyphrasename = "Question Answering"; | papers published in the area of Question Answering | CREATE TABLE `venue` (
`venueId` integer NOT NULL
, `venueName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`venueId`)
);
CREATE TABLE `author` (
`authorId` integer NOT NULL
, `authorName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`authorId`)
);
CREATE TABLE `dataset` (
`datasetId` integer NOT NULL
, `datasetName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`datasetId`)
);
CREATE TABLE `journal` (
`journalId` integer NOT NULL
, `journalName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`journalId`)
);
CREATE TABLE `keyphrase` (
`keyphraseId` integer NOT NULL
, `keyphraseName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`keyphraseId`)
);
CREATE TABLE `paper` (
`paperId` integer NOT NULL
, `title` varchar(300) DEFAULT NULL
, `venueId` integer DEFAULT NULL
, `year` integer DEFAULT NULL
, `numCiting` integer DEFAULT NULL
, `numCitedBy` integer DEFAULT NULL
, `journalId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`)
, FOREIGN KEY(`journalId`) REFERENCES `journal`(`journalId`)
, FOREIGN KEY(`venueId`) REFERENCES `venue`(`venueId`)
);
CREATE TABLE `cite` (
`citingPaperId` integer NOT NULL
, `citedPaperId` integer NOT NULL
, PRIMARY KEY (`citingPaperId`,`citedPaperId`)
, FOREIGN KEY(`citedpaperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`citingpaperId`) REFERENCES `paper`(`paperId`)
);
CREATE TABLE `paperDataset` (
`paperId` integer DEFAULT NULL
, `datasetId` integer DEFAULT NULL
, PRIMARY KEY (`datasetId`, `paperId`)
);
CREATE TABLE `paperKeyphrase` (
`paperId` integer DEFAULT NULL
, `keyphraseId` integer DEFAULT NULL
, PRIMARY KEY (`keyphraseId`,`paperId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`keyphraseId`) REFERENCES `keyphrase`(`keyphraseId`)
);
CREATE TABLE `writes` (
`paperId` integer DEFAULT NULL
, `authorId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`,`authorId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`authorId`) REFERENCES `author`(`authorId`)
);
|
customers_and_addresses | SELECT address_content FROM addresses WHERE city = "East Julianaside" AND state_province_county = "Texas" UNION SELECT address_content FROM addresses WHERE city = "Gleasonmouth" AND state_province_county = "Arizona" | What are all the addresses in East Julianaside, Texas or in Gleasonmouth, Arizona. | CREATE TABLE `Addresses` (
`address_id` INTEGER PRIMARY KEY,
`address_content` VARCHAR(80),
`city` VARCHAR(50),
`zip_postcode` VARCHAR(20),
`state_province_county` VARCHAR(50),
`country` VARCHAR(50),
`other_address_details` VARCHAR(255)
);
CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`product_details` VARCHAR(255)
);
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`payment_method` VARCHAR(15) NOT NULL,
`customer_name` VARCHAR(80),
`date_became_customer` DATETIME,
`other_customer_details` VARCHAR(255)
);
CREATE TABLE `Customer_Addresses` (
`customer_id` INTEGER NOT NULL,
`address_id` INTEGER NOT NULL,
`date_address_from` DATETIME NOT NULL,
`address_type` VARCHAR(15) NOT NULL,
`date_address_to` DATETIME,
FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ),
FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` )
);
CREATE TABLE `Customer_Contact_Channels` (
`customer_id` INTEGER NOT NULL,
`channel_code` VARCHAR(15) NOT NULL,
`active_from_date` DATETIME NOT NULL,
`active_to_date` DATETIME,
`contact_number` VARCHAR(50) NOT NULL,
FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` )
);
CREATE TABLE `Customer_Orders` (
`order_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`order_status` VARCHAR(15) NOT NULL,
`order_date` DATETIME,
`order_details` VARCHAR(255),
FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` )
);
CREATE TABLE `Order_Items` (
`order_id` INTEGER NOT NULL,
`product_id` INTEGER NOT NULL,
`order_quantity` VARCHAR(15),
FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ),
FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` )
);
|
activity_1 | SELECT rank , count(*) FROM Faculty GROUP BY rank | For each faculty rank, show the number of faculty members who have it. | create table Activity (
actid INTEGER PRIMARY KEY,
activity_name varchar(25)
);
create table Participates_in (
stuid INTEGER,
actid INTEGER,
FOREIGN KEY(stuid) REFERENCES Student(StuID),
FOREIGN KEY(actid) REFERENCES Activity(actid)
);
create table Faculty_Participates_in (
FacID INTEGER,
actid INTEGER,
FOREIGN KEY(FacID) REFERENCES Faculty(FacID),
FOREIGN KEY(actid) REFERENCES Activity(actid)
);
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 Faculty (
FacID INTEGER PRIMARY KEY,
Lname VARCHAR(15),
Fname VARCHAR(15),
Rank VARCHAR(15),
Sex VARCHAR(1),
Phone INTEGER,
Room VARCHAR(5),
Building VARCHAR(13)
);
|
cre_Theme_park | SELECT Location_Name FROM LOCATIONS WHERE Location_Name LIKE "%film%" | Find all the locations whose names contain the word "film". | CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
|
document_management | SELECT document_type_code FROM documents WHERE document_name = "David CV" | What is the type of the document named "David CV"? | CREATE TABLE `Roles` (
`role_code` VARCHAR(15) PRIMARY KEY,
`role_description` VARCHAR(80)
);
CREATE TABLE `Users` (
`user_id` INTEGER PRIMARY KEY,
`role_code` VARCHAR(15) NOT NULL,
`user_name` VARCHAR(40),
`user_login` VARCHAR(40),
`password` VARCHAR(40),
FOREIGN KEY (`role_code` ) REFERENCES `Roles`(`role_code` )
);
CREATE TABLE `Document_Structures` (
`document_structure_code` VARCHAR(15) PRIMARY KEY,
`parent_document_structure_code` VARCHAR(15),
`document_structure_description` VARCHAR(80)
);
CREATE TABLE `Functional_Areas` (
`functional_area_code` VARCHAR(15) PRIMARY KEY,
`parent_functional_area_code` VARCHAR(15),
`functional_area_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Images` (
`image_id` INTEGER PRIMARY KEY,
`image_alt_text` VARCHAR(80),
`image_name` VARCHAR(40),
`image_url` VARCHAR(255)
);
CREATE TABLE `Documents` (
`document_code` VARCHAR(15) PRIMARY KEY,
`document_structure_code` VARCHAR(15) NOT NULL,
`document_type_code` VARCHAR(15) NOT NULL,
`access_count` INTEGER,
`document_name` VARCHAR(80),
FOREIGN KEY (`document_structure_code` ) REFERENCES `Document_Structures`(`document_structure_code` )
);
CREATE TABLE `Document_Functional_Areas` (
`document_code` VARCHAR(15) NOT NULL,
`functional_area_code` VARCHAR(15) NOT NULL,
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` ),
FOREIGN KEY (`functional_area_code` ) REFERENCES `Functional_Areas`(`functional_area_code` )
);
CREATE TABLE `Document_Sections` (
`section_id` INTEGER PRIMARY KEY,
`document_code` VARCHAR(15) NOT NULL,
`section_sequence` INTEGER,
`section_code` VARCHAR(20),
`section_title` VARCHAR(80),
FOREIGN KEY (`document_code` ) REFERENCES `Documents`(`document_code` )
);
CREATE TABLE `Document_Sections_Images` (
`section_id` INTEGER NOT NULL,
`image_id` INTEGER NOT NULL,
PRIMARY KEY (`section_id`,`image_id`),
FOREIGN KEY (`section_id` ) REFERENCES `Document_Sections`(`section_id` ),
FOREIGN KEY (`image_id` ) REFERENCES `Images`(`image_id` )
);
|
club_1 | SELECT count(*) FROM club | Count the total number of clubs. | 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 Club (
ClubID INTEGER PRIMARY KEY,
ClubName VARCHAR(40),
ClubDesc VARCHAR(1024),
ClubLocation VARCHAR(40)
);
create table Member_of_club (
StuID INTEGER,
ClubID INTEGER,
Position VARCHAR(40),
FOREIGN KEY(StuID) REFERENCES Student(StuID),
FOREIGN KEY(ClubID) REFERENCES Club(ClubID)
);
|
icfp_1 | SELECT count(DISTINCT t1.title) FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = "Tokohu University" | Find the number of papers published by authors from the institution "Tokohu University". | null |
coffee_shop | SELECT Membership_card FROM member GROUP BY Membership_card HAVING count(*) > 5 | Which membership card has more than 5 members? | CREATE TABLE "shop" (
"Shop_ID" int,
"Address" text,
"Num_of_staff" text,
"Score" real,
"Open_Year" text,
PRIMARY KEY ("Shop_ID")
);
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Membership_card" text,
"Age" int,
"Time_of_purchase" int,
"Level_of_membership" int,
"Address" text,
PRIMARY KEY ("Member_ID")
);
CREATE TABLE "happy_hour" (
"HH_ID" int,
"Shop_ID" int,
"Month" text,
"Num_of_shaff_in_charge" int,
PRIMARY KEY ("HH_ID","Shop_ID","Month"),
FOREIGN KEY ("Shop_ID") REFERENCES `shop`("Shop_ID")
);
CREATE TABLE "happy_hour_member" (
"HH_ID" int,
"Member_ID" int,
"Total_amount" real,
PRIMARY KEY ("HH_ID","Member_ID"),
FOREIGN KEY ("Member_ID") REFERENCES `member`("Member_ID")
);
|
hospital_1 | SELECT name FROM physician WHERE POSITION LIKE '%senior%' | Find the name of physicians whose position title contains the word 'senior'. | CREATE TABLE Physician (
EmployeeID INTEGER NOT NULL,
Name VARCHAR(30) NOT NULL,
Position VARCHAR(30) NOT NULL,
SSN INTEGER NOT NULL,
CONSTRAINT pk_physician PRIMARY KEY(EmployeeID)
);
CREATE TABLE Department (
DepartmentID INTEGER NOT NULL,
Name VARCHAR(30) NOT NULL,
Head INTEGER NOT NULL,
CONSTRAINT pk_Department PRIMARY KEY(DepartmentID),
CONSTRAINT fk_Department_Physician_EmployeeID FOREIGN KEY(Head) REFERENCES Physician(EmployeeID)
);
CREATE TABLE Affiliated_With (
Physician INTEGER NOT NULL,
Department INTEGER NOT NULL,
PrimaryAffiliation BOOLEAN NOT NULL,
CONSTRAINT fk_Affiliated_With_Physician_EmployeeID FOREIGN KEY(Physician) REFERENCES Physician(EmployeeID),
CONSTRAINT fk_Affiliated_With_Department_DepartmentID FOREIGN KEY(Department) REFERENCES Department(DepartmentID),
PRIMARY KEY(Physician, Department)
);
CREATE TABLE Procedures (
Code INTEGER PRIMARY KEY NOT NULL,
Name VARCHAR(30) NOT NULL,
Cost REAL NOT NULL
);
CREATE TABLE Trained_In (
Physician INTEGER NOT NULL,
Treatment INTEGER NOT NULL,
CertificationDate DATETIME NOT NULL,
CertificationExpires DATETIME NOT NULL,
CONSTRAINT fk_Trained_In_Physician_EmployeeID FOREIGN KEY(Physician) REFERENCES Physician(EmployeeID),
CONSTRAINT fk_Trained_In_Procedures_Code FOREIGN KEY(Treatment) REFERENCES Procedures(Code),
PRIMARY KEY(Physician, Treatment)
);
CREATE TABLE Patient (
SSN INTEGER PRIMARY KEY NOT NULL,
Name VARCHAR(30) NOT NULL,
Address VARCHAR(30) NOT NULL,
Phone VARCHAR(30) NOT NULL,
InsuranceID INTEGER NOT NULL,
PCP INTEGER NOT NULL,
CONSTRAINT fk_Patient_Physician_EmployeeID FOREIGN KEY(PCP) REFERENCES Physician(EmployeeID)
);
CREATE TABLE Nurse (
EmployeeID INTEGER PRIMARY KEY NOT NULL,
Name VARCHAR(30) NOT NULL,
Position VARCHAR(30) NOT NULL,
Registered BOOLEAN NOT NULL,
SSN INTEGER NOT NULL
);
CREATE TABLE Appointment (
AppointmentID INTEGER PRIMARY KEY NOT NULL,
Patient INTEGER NOT NULL,
PrepNurse INTEGER,
Physician INTEGER NOT NULL,
Start DATETIME NOT NULL,
End DATETIME NOT NULL,
ExaminationRoom TEXT NOT NULL,
CONSTRAINT fk_Appointment_Patient_SSN FOREIGN KEY(Patient) REFERENCES Patient(SSN),
CONSTRAINT fk_Appointment_Nurse_EmployeeID FOREIGN KEY(PrepNurse) REFERENCES Nurse(EmployeeID),
CONSTRAINT fk_Appointment_Physician_EmployeeID FOREIGN KEY(Physician) REFERENCES Physician(EmployeeID)
);
CREATE TABLE Medication (
Code INTEGER PRIMARY KEY NOT NULL,
Name VARCHAR(30) NOT NULL,
Brand VARCHAR(30) NOT NULL,
Description VARCHAR(30) NOT NULL
);
CREATE TABLE Prescribes (
Physician INTEGER NOT NULL,
Patient INTEGER NOT NULL,
Medication INTEGER NOT NULL,
Date DATETIME NOT NULL,
Appointment INTEGER,
Dose VARCHAR(30) NOT NULL,
PRIMARY KEY(Physician, Patient, Medication, Date),
CONSTRAINT fk_Prescribes_Physician_EmployeeID FOREIGN KEY(Physician) REFERENCES Physician(EmployeeID),
CONSTRAINT fk_Prescribes_Patient_SSN FOREIGN KEY(Patient) REFERENCES Patient(SSN),
CONSTRAINT fk_Prescribes_Medication_Code FOREIGN KEY(Medication) REFERENCES Medication(Code),
CONSTRAINT fk_Prescribes_Appointment_AppointmentID FOREIGN KEY(Appointment) REFERENCES Appointment(AppointmentID)
);
CREATE TABLE Block (
BlockFloor INTEGER NOT NULL,
BlockCode INTEGER NOT NULL,
PRIMARY KEY(BlockFloor, BlockCode)
);
CREATE TABLE Room (
RoomNumber INTEGER PRIMARY KEY NOT NULL,
RoomType VARCHAR(30) NOT NULL,
BlockFloor INTEGER NOT NULL,
BlockCode INTEGER NOT NULL,
Unavailable BOOLEAN NOT NULL,
CONSTRAINT fk_Room_Block_PK FOREIGN KEY(BlockFloor, BlockCode) REFERENCES Block(BlockFloor, BlockCode)
);
CREATE TABLE On_Call (
Nurse INTEGER NOT NULL,
BlockFloor INTEGER NOT NULL,
BlockCode INTEGER NOT NULL,
OnCallStart DATETIME NOT NULL,
OnCallEnd DATETIME NOT NULL,
PRIMARY KEY(Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd),
CONSTRAINT fk_OnCall_Nurse_EmployeeID FOREIGN KEY(Nurse) REFERENCES Nurse(EmployeeID),
CONSTRAINT fk_OnCall_Block_Floor FOREIGN KEY(BlockFloor, BlockCode) REFERENCES Block(BlockFloor, BlockCode)
);
CREATE TABLE Stay (
StayID INTEGER PRIMARY KEY NOT NULL,
Patient INTEGER NOT NULL,
Room INTEGER NOT NULL,
StayStart DATETIME NOT NULL,
StayEnd DATETIME NOT NULL,
CONSTRAINT fk_Stay_Patient_SSN FOREIGN KEY(Patient) REFERENCES Patient(SSN),
CONSTRAINT fk_Stay_Room_Number FOREIGN KEY(Room) REFERENCES Room(RoomNumber)
);
CREATE TABLE Undergoes (
Patient INTEGER NOT NULL,
Procedures INTEGER NOT NULL,
Stay INTEGER NOT NULL,
DateUndergoes DATETIME NOT NULL,
Physician INTEGER NOT NULL,
AssistingNurse INTEGER,
PRIMARY KEY(Patient, Procedures, Stay, DateUndergoes),
CONSTRAINT fk_Undergoes_Patient_SSN FOREIGN KEY(Patient) REFERENCES Patient(SSN),
CONSTRAINT fk_Undergoes_Procedures_Code FOREIGN KEY(Procedures) REFERENCES Procedures(Code),
CONSTRAINT fk_Undergoes_Stay_StayID FOREIGN KEY(Stay) REFERENCES Stay(StayID),
CONSTRAINT fk_Undergoes_Physician_EmployeeID FOREIGN KEY(Physician) REFERENCES Physician(EmployeeID),
CONSTRAINT fk_Undergoes_Nurse_EmployeeID FOREIGN KEY(AssistingNurse) REFERENCES Nurse(EmployeeID)
);
|
student_1 | SELECT DISTINCT T1.firstname , T1.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE T1.grade = 1 EXCEPT SELECT T1.firstname , T1.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE T2.firstname = "OTHA" AND T2.lastname = "MOYER" | What are the first and last names of the first-grade students who are NOT taught by teacher OTHA MOYER? | null |
network_2 | SELECT T1.name , T1.age , T1.job FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Alice' AND T2.year = (SELECT max(YEAR) FROM PersonFriend WHERE friend = 'Alice') | What are the names, ages, and jobs of all people who are friends with Alice for the longest amount of time? | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
);
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
);
|
activity_1 | SELECT FacID FROM Faculty WHERE Sex = 'M' | Show ids for all the male faculty. | create table Activity (
actid INTEGER PRIMARY KEY,
activity_name varchar(25)
);
create table Participates_in (
stuid INTEGER,
actid INTEGER,
FOREIGN KEY(stuid) REFERENCES Student(StuID),
FOREIGN KEY(actid) REFERENCES Activity(actid)
);
create table Faculty_Participates_in (
FacID INTEGER,
actid INTEGER,
FOREIGN KEY(FacID) REFERENCES Faculty(FacID),
FOREIGN KEY(actid) REFERENCES Activity(actid)
);
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 Faculty (
FacID INTEGER PRIMARY KEY,
Lname VARCHAR(15),
Fname VARCHAR(15),
Rank VARCHAR(15),
Sex VARCHAR(1),
Phone INTEGER,
Room VARCHAR(5),
Building VARCHAR(13)
);
|
train_station | SELECT DISTINCT LOCATION FROM station | What are all locations of train stations? | CREATE TABLE "station" (
"Station_ID" int,
"Name" text,
"Annual_entry_exit" real,
"Annual_interchanges" real,
"Total_Passengers" real,
"Location" text,
"Main_Services" text,
"Number_of_Platforms" int,
PRIMARY KEY ("Station_ID")
);
CREATE TABLE "train" (
"Train_ID" int,
"Name" text,
"Time" text,
"Service" text,
PRIMARY KEY ("Train_ID")
);
CREATE TABLE "train_station" (
"Train_ID" int,
"Station_ID" int,
PRIMARY KEY ("Train_ID","Station_ID"),
FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"),
FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID")
);
|
musical | SELECT T1.Name , T2.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID | What are the names of actors and the musicals that they are in? | CREATE TABLE "musical" (
"Musical_ID" int,
"Name" text,
"Year" int,
"Award" text,
"Category" text,
"Nominee" text,
"Result" text,
PRIMARY KEY ("Musical_ID")
);
CREATE TABLE "actor" (
"Actor_ID" int,
"Name" text,
"Musical_ID" int,
"Character" text,
"Duration" text,
"age" int,
PRIMARY KEY ("Actor_ID"),
FOREIGN KEY ("Musical_ID") REFERENCES "actor"("Actor_ID")
);
|
scholar | SELECT DISTINCT t3.journalid , t4.venueid FROM venue AS t4 JOIN paper AS t3 ON t4.venueid = t3.venueid JOIN writes AS t2 ON t2.paperid = t3.paperid JOIN author AS t1 ON t2.authorid = t1.authorid WHERE t1.authorname = "Peter Mertens"; | in what venues does Peter Mertens publish ? | CREATE TABLE `venue` (
`venueId` integer NOT NULL
, `venueName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`venueId`)
);
CREATE TABLE `author` (
`authorId` integer NOT NULL
, `authorName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`authorId`)
);
CREATE TABLE `dataset` (
`datasetId` integer NOT NULL
, `datasetName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`datasetId`)
);
CREATE TABLE `journal` (
`journalId` integer NOT NULL
, `journalName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`journalId`)
);
CREATE TABLE `keyphrase` (
`keyphraseId` integer NOT NULL
, `keyphraseName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`keyphraseId`)
);
CREATE TABLE `paper` (
`paperId` integer NOT NULL
, `title` varchar(300) DEFAULT NULL
, `venueId` integer DEFAULT NULL
, `year` integer DEFAULT NULL
, `numCiting` integer DEFAULT NULL
, `numCitedBy` integer DEFAULT NULL
, `journalId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`)
, FOREIGN KEY(`journalId`) REFERENCES `journal`(`journalId`)
, FOREIGN KEY(`venueId`) REFERENCES `venue`(`venueId`)
);
CREATE TABLE `cite` (
`citingPaperId` integer NOT NULL
, `citedPaperId` integer NOT NULL
, PRIMARY KEY (`citingPaperId`,`citedPaperId`)
, FOREIGN KEY(`citedpaperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`citingpaperId`) REFERENCES `paper`(`paperId`)
);
CREATE TABLE `paperDataset` (
`paperId` integer DEFAULT NULL
, `datasetId` integer DEFAULT NULL
, PRIMARY KEY (`datasetId`, `paperId`)
);
CREATE TABLE `paperKeyphrase` (
`paperId` integer DEFAULT NULL
, `keyphraseId` integer DEFAULT NULL
, PRIMARY KEY (`keyphraseId`,`paperId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`keyphraseId`) REFERENCES `keyphrase`(`keyphraseId`)
);
CREATE TABLE `writes` (
`paperId` integer DEFAULT NULL
, `authorId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`,`authorId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`authorId`) REFERENCES `author`(`authorId`)
);
|
product_catalog | SELECT t1.attribute_name , t1.attribute_id FROM Attribute_Definitions AS t1 JOIN Catalog_Contents_Additional_Attributes AS t2 ON t1.attribute_id = t2.attribute_id WHERE t2.attribute_value = 0 | Which attribute definitions have attribute value 0? Give me the attribute name and attribute ID. | CREATE TABLE `Attribute_Definitions` (
`attribute_id` INTEGER PRIMARY KEY,
`attribute_name` VARCHAR(30),
`attribute_data_type` VARCHAR(10)
);
CREATE TABLE `Catalogs` (
`catalog_id` INTEGER PRIMARY KEY,
`catalog_name` VARCHAR(50),
`catalog_publisher` VARCHAR(80),
`date_of_publication` DATETIME,
`date_of_latest_revision` DATETIME
);
CREATE TABLE `Catalog_Structure` (
`catalog_level_number` INTEGER PRIMARY KEY,
`catalog_id` INTEGER NOT NULL,
`catalog_level_name` VARCHAR(50),
FOREIGN KEY (`catalog_id` ) REFERENCES `Catalogs`(`catalog_id` )
);
CREATE TABLE `Catalog_Contents` (
`catalog_entry_id` INTEGER PRIMARY KEY,
`catalog_level_number` INTEGER NOT NULL,
`parent_entry_id` INTEGER,
`previous_entry_id` INTEGER,
`next_entry_id` INTEGER,
`catalog_entry_name` VARCHAR(80),
`product_stock_number` VARCHAR(50),
`price_in_dollars` DOUBLE NULL,
`price_in_euros` DOUBLE NULL,
`price_in_pounds` DOUBLE NULL,
`capacity` VARCHAR(20),
`length` VARCHAR(20),
`height` VARCHAR(20),
`width` VARCHAR(20),
FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` )
);
CREATE TABLE `Catalog_Contents_Additional_Attributes` (
`catalog_entry_id` INTEGER NOT NULL,
`catalog_level_number` INTEGER NOT NULL,
`attribute_id` INTEGER NOT NULL,
`attribute_value` VARCHAR(255) NOT NULL,
FOREIGN KEY (`catalog_entry_id` ) REFERENCES `Catalog_Contents`(`catalog_entry_id` ),
FOREIGN KEY (`catalog_level_number` ) REFERENCES `Catalog_Structure`(`catalog_level_number` )
);
|
geo | SELECT population FROM city WHERE population = ( SELECT MAX ( population ) FROM city WHERE state_name = "alaska" ) AND state_name = "alaska"; | how large is the largest city in alaska | CREATE TABLE `state` (
`state_name` text
, `population` integer DEFAULT NULL
, `area` double DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `capital` text
, `density` double DEFAULT NULL
, PRIMARY KEY (`state_name`)
);
CREATE TABLE `city` (
`city_name` text
, `population` integer DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `state_name` text
, PRIMARY KEY (`city_name`,`state_name`)
, FOREIGN KEY(`state_name`) REFERENCES `state`(`state_name`)
);
CREATE TABLE `border_info` (
`state_name` text
, `border` text
, PRIMARY KEY (`border`,`state_name`)
, FOREIGN KEY(`state_name`) REFERENCES `state`(`state_name`)
, FOREIGN KEY(`border`) REFERENCES `state`(`state_name`)
);
CREATE TABLE `highlow` (
`state_name` text
, `highest_elevation` text
, `lowest_point` text
, `highest_point` text
, `lowest_elevation` text
, PRIMARY KEY (`state_name`)
, FOREIGN KEY(`state_name`) REFERENCES `state`(`state_name`)
);
CREATE TABLE `lake` (
`lake_name` text
, `area` double DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `state_name` text
);
CREATE TABLE `mountain` (
`mountain_name` text
, `mountain_altitude` integer DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `state_name` text
, PRIMARY KEY (`mountain_name`, `state_name`)
, FOREIGN KEY(`state_name`) REFERENCES `state`(`state_name`)
);
CREATE TABLE `river` (
`river_name` text
, `length` integer DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `traverse` text
, PRIMARY KEY (`river_name`)
, FOREIGN KEY(`traverse`) REFERENCES `state`(`state_name`)
); |
activity_1 | SELECT DISTINCT T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID JOIN activity AS T3 ON T2.actid = T2.actid WHERE T3.activity_name = 'Canoeing' OR T3.activity_name = 'Kayaking' | Which faculty members are playing either Canoeing or Kayaking? Tell me their first names. | create table Activity (
actid INTEGER PRIMARY KEY,
activity_name varchar(25)
);
create table Participates_in (
stuid INTEGER,
actid INTEGER,
FOREIGN KEY(stuid) REFERENCES Student(StuID),
FOREIGN KEY(actid) REFERENCES Activity(actid)
);
create table Faculty_Participates_in (
FacID INTEGER,
actid INTEGER,
FOREIGN KEY(FacID) REFERENCES Faculty(FacID),
FOREIGN KEY(actid) REFERENCES Activity(actid)
);
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 Faculty (
FacID INTEGER PRIMARY KEY,
Lname VARCHAR(15),
Fname VARCHAR(15),
Rank VARCHAR(15),
Sex VARCHAR(1),
Phone INTEGER,
Room VARCHAR(5),
Building VARCHAR(13)
);
|
network_2 | SELECT DISTINCT T4.name FROM PersonFriend AS T1 JOIN Person AS T2 ON T1.name = T2.name JOIN PersonFriend AS T3 ON T1.friend = T3.name JOIN PersonFriend AS T4 ON T3.friend = T4.name WHERE T2.name = 'Alice' AND T4.name != 'Alice' | Find Alice's friends of friends. | CREATE TABLE Person (
name varchar(20) PRIMARY KEY,
age INTEGER,
city TEXT,
gender TEXT,
job TEXT
);
CREATE TABLE PersonFriend (
name varchar(20),
friend varchar(20),
year INTEGER,
FOREIGN KEY (name) REFERENCES Person(name),
FOREIGN KEY (friend) REFERENCES Person(name)
);
|
geo | SELECT state_name FROM highlow WHERE highest_elevation > ( SELECT highest_elevation FROM highlow WHERE state_name = "colorado" ); | which states have points that are higher than the highest point in colorado | CREATE TABLE `state` (
`state_name` text
, `population` integer DEFAULT NULL
, `area` double DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `capital` text
, `density` double DEFAULT NULL
, PRIMARY KEY (`state_name`)
);
CREATE TABLE `city` (
`city_name` text
, `population` integer DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `state_name` text
, PRIMARY KEY (`city_name`,`state_name`)
, FOREIGN KEY(`state_name`) REFERENCES `state`(`state_name`)
);
CREATE TABLE `border_info` (
`state_name` text
, `border` text
, PRIMARY KEY (`border`,`state_name`)
, FOREIGN KEY(`state_name`) REFERENCES `state`(`state_name`)
, FOREIGN KEY(`border`) REFERENCES `state`(`state_name`)
);
CREATE TABLE `highlow` (
`state_name` text
, `highest_elevation` text
, `lowest_point` text
, `highest_point` text
, `lowest_elevation` text
, PRIMARY KEY (`state_name`)
, FOREIGN KEY(`state_name`) REFERENCES `state`(`state_name`)
);
CREATE TABLE `lake` (
`lake_name` text
, `area` double DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `state_name` text
);
CREATE TABLE `mountain` (
`mountain_name` text
, `mountain_altitude` integer DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `state_name` text
, PRIMARY KEY (`mountain_name`, `state_name`)
, FOREIGN KEY(`state_name`) REFERENCES `state`(`state_name`)
);
CREATE TABLE `river` (
`river_name` text
, `length` integer DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `traverse` text
, PRIMARY KEY (`river_name`)
, FOREIGN KEY(`traverse`) REFERENCES `state`(`state_name`)
); |
customers_and_invoices | SELECT order_id , count(*) FROM Invoices GROUP BY order_id | How many invoices correspond to each order id? | CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(50),
`customer_middle_initial` VARCHAR(1),
`customer_last_name` VARCHAR(50),
`gender` VARCHAR(1),
`email_address` VARCHAR(255),
`login_name` VARCHAR(80),
`login_password` VARCHAR(20),
`phone_number` VARCHAR(255),
`town_city` VARCHAR(50),
`state_county_province` VARCHAR(50),
`country` VARCHAR(50)
);
CREATE TABLE `Orders` (
`order_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`date_order_placed` DATETIME NOT NULL,
`order_details` VARCHAR(255),
FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` )
);
CREATE TABLE `Invoices` (
`invoice_number` INTEGER PRIMARY KEY,
`order_id` INTEGER NOT NULL,
`invoice_date` DATETIME,
FOREIGN KEY (`order_id` ) REFERENCES `Orders`(`order_id` )
);
CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`date_account_opened` DATETIME,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255),
FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` )
);
CREATE TABLE `Product_Categories` (
`production_type_code` VARCHAR(15) PRIMARY KEY,
`product_type_description` VARCHAR(80),
`vat_rating` DECIMAL(19,4)
);
CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`parent_product_id` INTEGER,
`production_type_code` VARCHAR(15) NOT NULL,
`unit_price` DECIMAL(19,4),
`product_name` VARCHAR(80),
`product_color` VARCHAR(20),
`product_size` VARCHAR(20),
FOREIGN KEY (`production_type_code` ) REFERENCES `Product_Categories`(`production_type_code` )
);
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`account_id` INTEGER NOT NULL,
`invoice_number` INTEGER,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DECIMAL(19,4),
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`invoice_number` ) REFERENCES `Invoices`(`invoice_number` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
);
CREATE TABLE `Order_Items` (
`order_item_id` INTEGER PRIMARY KEY,
`order_id` INTEGER NOT NULL,
`product_id` INTEGER NOT NULL,
`product_quantity` VARCHAR(50),
`other_order_item_details` VARCHAR(255),
FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ),
FOREIGN KEY (`order_id` ) REFERENCES `Orders`(`order_id` )
);
CREATE TABLE `Invoice_Line_Items` (
`order_item_id` INTEGER NOT NULL,
`invoice_number` INTEGER NOT NULL,
`product_id` INTEGER NOT NULL,
`product_title` VARCHAR(80),
`product_quantity` VARCHAR(50),
`product_price` DECIMAL(19,4),
`derived_product_cost` DECIMAL(19,4),
`derived_vat_payable` DECIMAL(19,4),
`derived_total_cost` DECIMAL(19,4),
FOREIGN KEY (`order_item_id` ) REFERENCES `Order_Items`(`order_item_id` ),
FOREIGN KEY (`invoice_number` ) REFERENCES `Invoices`(`invoice_number` ),
FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` )
);
|
customers_and_invoices | SELECT DISTINCT product_color FROM Products | What are the different product colors? | CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(50),
`customer_middle_initial` VARCHAR(1),
`customer_last_name` VARCHAR(50),
`gender` VARCHAR(1),
`email_address` VARCHAR(255),
`login_name` VARCHAR(80),
`login_password` VARCHAR(20),
`phone_number` VARCHAR(255),
`town_city` VARCHAR(50),
`state_county_province` VARCHAR(50),
`country` VARCHAR(50)
);
CREATE TABLE `Orders` (
`order_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`date_order_placed` DATETIME NOT NULL,
`order_details` VARCHAR(255),
FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` )
);
CREATE TABLE `Invoices` (
`invoice_number` INTEGER PRIMARY KEY,
`order_id` INTEGER NOT NULL,
`invoice_date` DATETIME,
FOREIGN KEY (`order_id` ) REFERENCES `Orders`(`order_id` )
);
CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`date_account_opened` DATETIME,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255),
FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` )
);
CREATE TABLE `Product_Categories` (
`production_type_code` VARCHAR(15) PRIMARY KEY,
`product_type_description` VARCHAR(80),
`vat_rating` DECIMAL(19,4)
);
CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`parent_product_id` INTEGER,
`production_type_code` VARCHAR(15) NOT NULL,
`unit_price` DECIMAL(19,4),
`product_name` VARCHAR(80),
`product_color` VARCHAR(20),
`product_size` VARCHAR(20),
FOREIGN KEY (`production_type_code` ) REFERENCES `Product_Categories`(`production_type_code` )
);
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`account_id` INTEGER NOT NULL,
`invoice_number` INTEGER,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DECIMAL(19,4),
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`invoice_number` ) REFERENCES `Invoices`(`invoice_number` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
);
CREATE TABLE `Order_Items` (
`order_item_id` INTEGER PRIMARY KEY,
`order_id` INTEGER NOT NULL,
`product_id` INTEGER NOT NULL,
`product_quantity` VARCHAR(50),
`other_order_item_details` VARCHAR(255),
FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ),
FOREIGN KEY (`order_id` ) REFERENCES `Orders`(`order_id` )
);
CREATE TABLE `Invoice_Line_Items` (
`order_item_id` INTEGER NOT NULL,
`invoice_number` INTEGER NOT NULL,
`product_id` INTEGER NOT NULL,
`product_title` VARCHAR(80),
`product_quantity` VARCHAR(50),
`product_price` DECIMAL(19,4),
`derived_product_cost` DECIMAL(19,4),
`derived_vat_payable` DECIMAL(19,4),
`derived_total_cost` DECIMAL(19,4),
FOREIGN KEY (`order_item_id` ) REFERENCES `Order_Items`(`order_item_id` ),
FOREIGN KEY (`invoice_number` ) REFERENCES `Invoices`(`invoice_number` ),
FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` )
);
|
music_1 | SELECT count(*) , formats FROM files GROUP BY formats | For each file format, return the number of artists who released songs in that format. | create table genre(
g_name varchar2(20) not null,
rating varchar2(10),
most_popular_in varchar2(50),
primary key(g_name)
);
create table artist(
artist_name varchar2(50) not null,
country varchar2(20),
gender varchar2(20),
preferred_genre varchar2(50),
constraint a_name primary key(artist_name),
foreign key(preferred_genre) references genre(g_name) ON DELETE CASCADE
);
create table files(
f_id number(10) not null,
artist_name varchar2(50),
file_size varchar2(20),
duration varchar2(20),
formats varchar2(20),
primary key(f_id),
foreign key(artist_name) references artist(artist_name) ON DELETE CASCADE
);
create table song(
song_name varchar2(50),
artist_name varchar2(50),
country varchar2(20),
f_id number(10),
genre_is varchar2(20),
rating number(10) check(rating>0 and rating<11),
languages varchar2(20),
releasedate Date,
resolution number(10) not null,
constraint s_name primary key(song_name),
foreign key(artist_name) references artist(artist_name) ON DELETE CASCADE,
foreign key(f_id) references files(f_id) ON DELETE CASCADE,
foreign key(genre_is) references genre(g_name) ON DELETE CASCADE
);
|
hr_1 | SELECT employee_id FROM job_history GROUP BY employee_id HAVING COUNT(*) >= 2 | What are the employee ids for employees who have held two or more jobs? | CREATE TABLE IF NOT EXISTS `regions` (
`REGION_ID` decimal(5,0) NOT NULL,
`REGION_NAME` varchar(25) DEFAULT NULL,
PRIMARY KEY (`REGION_ID`)
);
CREATE TABLE IF NOT EXISTS `countries` (
`COUNTRY_ID` varchar(2) NOT NULL,
`COUNTRY_NAME` varchar(40) DEFAULT NULL,
`REGION_ID` decimal(10,0) DEFAULT NULL,
PRIMARY KEY (`COUNTRY_ID`),
FOREIGN KEY (`REGION_ID`) REFERENCES regions (`REGION_ID`)
);
CREATE TABLE IF NOT EXISTS `departments` (
`DEPARTMENT_ID` decimal(4,0) NOT NULL DEFAULT '0',
`DEPARTMENT_NAME` varchar(30) NOT NULL,
`MANAGER_ID` decimal(6,0) DEFAULT NULL,
`LOCATION_ID` decimal(4,0) DEFAULT NULL,
PRIMARY KEY (`DEPARTMENT_ID`)
);
CREATE TABLE IF NOT EXISTS `jobs` (
`JOB_ID` varchar(10) NOT NULL DEFAULT '',
`JOB_TITLE` varchar(35) NOT NULL,
`MIN_SALARY` decimal(6,0) DEFAULT NULL,
`MAX_SALARY` decimal(6,0) DEFAULT NULL,
PRIMARY KEY (`JOB_ID`)
);
CREATE TABLE IF NOT EXISTS `employees` (
`EMPLOYEE_ID` decimal(6,0) NOT NULL DEFAULT '0',
`FIRST_NAME` varchar(20) DEFAULT NULL,
`LAST_NAME` varchar(25) NOT NULL,
`EMAIL` varchar(25) NOT NULL,
`PHONE_NUMBER` varchar(20) DEFAULT NULL,
`HIRE_DATE` date NOT NULL,
`JOB_ID` varchar(10) NOT NULL,
`SALARY` decimal(8,2) DEFAULT NULL,
`COMMISSION_PCT` decimal(2,2) DEFAULT NULL,
`MANAGER_ID` decimal(6,0) DEFAULT NULL,
`DEPARTMENT_ID` decimal(4,0) DEFAULT NULL,
PRIMARY KEY (`EMPLOYEE_ID`),
FOREIGN KEY (`DEPARTMENT_ID`) REFERENCES departments(`DEPARTMENT_ID`),
FOREIGN KEY (`JOB_ID`) REFERENCES jobs(`JOB_ID`)
);
CREATE TABLE IF NOT EXISTS `job_history` (
`EMPLOYEE_ID` decimal(6,0) NOT NULL,
`START_DATE` date NOT NULL,
`END_DATE` date NOT NULL,
`JOB_ID` varchar(10) NOT NULL,
`DEPARTMENT_ID` decimal(4,0) DEFAULT NULL,
PRIMARY KEY (`EMPLOYEE_ID`,`START_DATE`),
FOREIGN KEY (`EMPLOYEE_ID`) REFERENCES employees(`EMPLOYEE_ID`),
FOREIGN KEY (`DEPARTMENT_ID`) REFERENCES departments(`DEPARTMENT_ID`),
FOREIGN KEY (`JOB_ID`) REFERENCES jobs(`JOB_ID`)
);
CREATE TABLE IF NOT EXISTS `locations` (
`LOCATION_ID` decimal(4,0) NOT NULL DEFAULT '0',
`STREET_ADDRESS` varchar(40) DEFAULT NULL,
`POSTAL_CODE` varchar(12) DEFAULT NULL,
`CITY` varchar(30) NOT NULL,
`STATE_PROVINCE` varchar(25) DEFAULT NULL,
`COUNTRY_ID` varchar(2) DEFAULT NULL,
PRIMARY KEY (`LOCATION_ID`),
FOREIGN KEY (`COUNTRY_ID`) REFERENCES countries(`COUNTRY_ID`)
);
|
college_2 | SELECT count(*) , building FROM classroom WHERE capacity > 50 GROUP BY building | How many rooms in each building have a capacity of over 50? | null |
college_2 | SELECT name , dept_name FROM student ORDER BY tot_cred | What are the names of students and their respective departments, ordered by number of credits from least to greatest? | null |
scholar | SELECT DISTINCT COUNT ( t2.paperid ) FROM writes AS t2 JOIN author AS t1 ON t2.authorid = t1.authorid JOIN paper AS t3 ON t2.paperid = t3.paperid WHERE t1.authorname = "michael i. jordan" AND t3.year = 2016; | How many papers did michael i. jordan publish in 2016 | CREATE TABLE `venue` (
`venueId` integer NOT NULL
, `venueName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`venueId`)
);
CREATE TABLE `author` (
`authorId` integer NOT NULL
, `authorName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`authorId`)
);
CREATE TABLE `dataset` (
`datasetId` integer NOT NULL
, `datasetName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`datasetId`)
);
CREATE TABLE `journal` (
`journalId` integer NOT NULL
, `journalName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`journalId`)
);
CREATE TABLE `keyphrase` (
`keyphraseId` integer NOT NULL
, `keyphraseName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`keyphraseId`)
);
CREATE TABLE `paper` (
`paperId` integer NOT NULL
, `title` varchar(300) DEFAULT NULL
, `venueId` integer DEFAULT NULL
, `year` integer DEFAULT NULL
, `numCiting` integer DEFAULT NULL
, `numCitedBy` integer DEFAULT NULL
, `journalId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`)
, FOREIGN KEY(`journalId`) REFERENCES `journal`(`journalId`)
, FOREIGN KEY(`venueId`) REFERENCES `venue`(`venueId`)
);
CREATE TABLE `cite` (
`citingPaperId` integer NOT NULL
, `citedPaperId` integer NOT NULL
, PRIMARY KEY (`citingPaperId`,`citedPaperId`)
, FOREIGN KEY(`citedpaperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`citingpaperId`) REFERENCES `paper`(`paperId`)
);
CREATE TABLE `paperDataset` (
`paperId` integer DEFAULT NULL
, `datasetId` integer DEFAULT NULL
, PRIMARY KEY (`datasetId`, `paperId`)
);
CREATE TABLE `paperKeyphrase` (
`paperId` integer DEFAULT NULL
, `keyphraseId` integer DEFAULT NULL
, PRIMARY KEY (`keyphraseId`,`paperId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`keyphraseId`) REFERENCES `keyphrase`(`keyphraseId`)
);
CREATE TABLE `writes` (
`paperId` integer DEFAULT NULL
, `authorId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`,`authorId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`authorId`) REFERENCES `author`(`authorId`)
);
|
university_basketball | SELECT max(Enrollment) FROM university | What is the maximum enrollment across all schools? | CREATE TABLE "basketball_match" (
"Team_ID" int,
"School_ID" int,
"Team_Name" text,
"ACC_Regular_Season" text,
"ACC_Percent" text,
"ACC_Home" text,
"ACC_Road" text,
"All_Games" text,
"All_Games_Percent" int,
"All_Home" text,
"All_Road" text,
"All_Neutral" text,
PRIMARY KEY ("Team_ID"),
FOREIGN KEY (`School_ID`) REFERENCES `university`(`School_ID`)
);
CREATE TABLE "university" (
"School_ID" int,
"School" text,
"Location" text,
"Founded" real,
"Affiliation" text,
"Enrollment" real,
"Nickname" text,
"Primary_conference" text,
PRIMARY KEY ("School_ID")
);
|
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 (
dormid INTEGER,
dorm_name VARCHAR(20),
student_capacity INTEGER,
gender VARCHAR(1)
) ;
create table Dorm_amenity (
amenid INTEGER,
amenity_name VARCHAR(25)
) ;
create table Has_amenity (
dormid INTEGER,
amenid INTEGER,
FOREIGN KEY (dormid) REFERENCES `Dorm`(dormid),
FOREIGN KEY (amenid) REFERENCES `Dorm_amenity`(amenid)
);
create table Lives_in (
stuid INTEGER,
dormid INTEGER,
room_number INTEGER,
FOREIGN KEY (stuid) REFERENCES `Student`(StuID),
FOREIGN KEY (dormid) REFERENCES `Dorm`(dormid)
);
|
sakila_1 | SELECT title , rental_rate FROM film ORDER BY rental_rate DESC LIMIT 1 | Which film has the highest rental rate? And what is the rate? | CREATE TABLE actor (
actor_id SMALLINT UNSIGNED NOT NULL,
first_name VARCHAR(45) NOT NULL,
last_name VARCHAR(45) NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (actor_id)
);
CREATE TABLE address (
address_id SMALLINT UNSIGNED NOT NULL,
address VARCHAR(50) NOT NULL,
address2 VARCHAR(50) DEFAULT NULL,
district VARCHAR(20) NOT NULL,
city_id SMALLINT UNSIGNED NOT NULL,
postal_code VARCHAR(10) DEFAULT NULL,
phone VARCHAR(20) NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (address_id),
FOREIGN KEY (city_id) REFERENCES city (city_id)
);
CREATE TABLE category (
category_id TINYINT UNSIGNED NOT NULL,
name VARCHAR(25) NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (category_id)
);
CREATE TABLE city (
city_id SMALLINT UNSIGNED NOT NULL,
city VARCHAR(50) NOT NULL,
country_id SMALLINT UNSIGNED NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (city_id),
FOREIGN KEY (country_id) REFERENCES country (country_id)
);
CREATE TABLE country (
country_id SMALLINT UNSIGNED NOT NULL,
country VARCHAR(50) NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (country_id)
);
CREATE TABLE customer (
customer_id SMALLINT UNSIGNED NOT NULL,
store_id TINYINT UNSIGNED NOT NULL,
first_name VARCHAR(45) NOT NULL,
last_name VARCHAR(45) NOT NULL,
email VARCHAR(50) DEFAULT NULL,
address_id SMALLINT UNSIGNED NOT NULL,
active BOOLEAN NOT NULL DEFAULT TRUE,
create_date DATETIME NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (customer_id),
FOREIGN KEY (address_id) REFERENCES address (address_id),
FOREIGN KEY (store_id) REFERENCES store (store_id)
);
CREATE TABLE film (
film_id SMALLINT UNSIGNED NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT DEFAULT NULL,
release_year YEAR DEFAULT NULL,
language_id TINYINT UNSIGNED NOT NULL,
original_language_id TINYINT UNSIGNED DEFAULT NULL,
rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3,
rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99,
length SMALLINT UNSIGNED DEFAULT NULL,
replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99,
rating DEFAULT 'G',
special_features DEFAULT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (film_id),
FOREIGN KEY (language_id) REFERENCES language (language_id),
FOREIGN KEY (original_language_id) REFERENCES language (language_id)
);
CREATE TABLE film_actor (
actor_id SMALLINT UNSIGNED NOT NULL,
film_id SMALLINT UNSIGNED NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (actor_id,film_id),
FOREIGN KEY (actor_id) REFERENCES actor (actor_id),
FOREIGN KEY (film_id) REFERENCES film (film_id)
);
CREATE TABLE film_category (
film_id SMALLINT UNSIGNED NOT NULL,
category_id TINYINT UNSIGNED NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (film_id, category_id),
FOREIGN KEY (film_id) REFERENCES film (film_id),
FOREIGN KEY (category_id) REFERENCES category (category_id)
);
CREATE TABLE film_text (
film_id SMALLINT NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT,
PRIMARY KEY (film_id)
);
CREATE TABLE inventory (
inventory_id MEDIUMINT UNSIGNED NOT NULL,
film_id SMALLINT UNSIGNED NOT NULL,
store_id TINYINT UNSIGNED NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (inventory_id),
FOREIGN KEY (store_id) REFERENCES store (store_id),
FOREIGN KEY (film_id) REFERENCES film (film_id)
);
CREATE TABLE language (
language_id TINYINT UNSIGNED NOT NULL,
name CHAR(20) NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (language_id)
);
CREATE TABLE payment (
payment_id SMALLINT UNSIGNED NOT NULL,
customer_id SMALLINT UNSIGNED NOT NULL,
staff_id TINYINT UNSIGNED NOT NULL,
rental_id INT DEFAULT NULL,
amount DECIMAL(5,2) NOT NULL,
payment_date DATETIME NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (payment_id),
FOREIGN KEY (rental_id) REFERENCES rental (rental_id),
FOREIGN KEY (customer_id) REFERENCES customer (customer_id),
FOREIGN KEY (staff_id) REFERENCES staff (staff_id)
);
CREATE TABLE rental (
rental_id INT NOT NULL,
rental_date DATETIME NOT NULL,
inventory_id MEDIUMINT UNSIGNED NOT NULL,
customer_id SMALLINT UNSIGNED NOT NULL,
return_date DATETIME DEFAULT NULL,
staff_id TINYINT UNSIGNED NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (rental_id),
FOREIGN KEY (staff_id) REFERENCES staff (staff_id),
FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id),
FOREIGN KEY (customer_id) REFERENCES customer (customer_id)
);
CREATE TABLE staff (
staff_id TINYINT UNSIGNED NOT NULL,
first_name VARCHAR(45) NOT NULL,
last_name VARCHAR(45) NOT NULL,
address_id SMALLINT UNSIGNED NOT NULL,
picture BLOB DEFAULT NULL,
email VARCHAR(50) DEFAULT NULL,
store_id TINYINT UNSIGNED NOT NULL,
active BOOLEAN NOT NULL DEFAULT TRUE,
username VARCHAR(16) NOT NULL,
password VARCHAR(40) DEFAULT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (staff_id),
--FOREIGN KEY (store_id) REFERENCES store (store_id),
FOREIGN KEY (address_id) REFERENCES address (address_id)
);
CREATE TABLE store (
store_id TINYINT UNSIGNED NOT NULL,
manager_staff_id TINYINT UNSIGNED NOT NULL,
address_id SMALLINT UNSIGNED NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (store_id),
FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id),
FOREIGN KEY (address_id) REFERENCES address (address_id)
);
|
formula_1 | SELECT T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid ORDER BY T2.milliseconds LIMIT 1 | What is the forename and surname of the driver with the shortest laptime? | null |
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. | 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)
);
CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`product_type_code` VARCHAR(15),
`product_name` VARCHAR(80),
`product_price` DOUBLE NULL
);
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`payment_method_code` VARCHAR(15),
`customer_number` VARCHAR(20),
`customer_name` VARCHAR(80),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(80),
`customer_email` VARCHAR(80)
);
CREATE TABLE `Contacts` (
`contact_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`gender` VARCHAR(1),
`first_name` VARCHAR(80),
`last_name` VARCHAR(50),
`contact_phone` VARCHAR(80)
);
CREATE TABLE `Customer_Address_History` (
`customer_id` INTEGER NOT NULL,
`address_id` INTEGER NOT NULL,
`date_from` DATETIME NOT NULL,
`date_to` DATETIME,
FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ),
FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` )
);
CREATE TABLE `Customer_Orders` (
`order_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`order_date` DATETIME NOT NULL,
`order_status_code` VARCHAR(15),
FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` )
);
CREATE TABLE `Order_Items` (
`order_item_id` INTEGER NOT NULL ,
`order_id` INTEGER NOT NULL,
`product_id` INTEGER NOT NULL,
`order_quantity` VARCHAR(80),
FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ),
FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` )
);
|
climbing | SELECT Name FROM mountain WHERE Height > 5000 OR Prominence > 1000 | What are the names of mountains that have a height of over 5000 or a prominence of over 1000? | CREATE TABLE "mountain" (
"Mountain_ID" int,
"Name" text,
"Height" real,
"Prominence" real,
"Range" text,
"Country" text,
PRIMARY KEY ("Mountain_ID")
);
CREATE TABLE "climber" (
"Climber_ID" int,
"Name" text,
"Country" text,
"Time" text,
"Points" real,
"Mountain_ID" int,
PRIMARY KEY ("Climber_ID"),
FOREIGN KEY ("Mountain_ID") REFERENCES "mountain"("Mountain_ID")
);
|
medicine_enzyme_interaction | SELECT DISTINCT T1.name , T1.location , T1.product FROM enzyme AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.enzyme_id = T1.id WHERE T2.interaction_type = 'inhibitor' | What are the distinct name, location and products of the enzymes which has any 'inhibitor' interaction? | CREATE TABLE "medicine" (
"id" int,
"name" text,
"Trade_Name" text,
"FDA_approved" text,
primary key ("id")
);
CREATE TABLE "enzyme" (
"id" int,
"name" text,
"Location" text,
"Product" text,
"Chromosome" text,
"OMIM" int,
"Porphyria" text,
primary key ("id")
);
CREATE TABLE "medicine_enzyme_interaction" (
"enzyme_id" int,
"medicine_id" int,
"interaction_type" text,
primary key ("enzyme_id", "medicine_id"),
foreign key ("enzyme_id") references `enzyme`("id"),
foreign key ("medicine_id") references `medicine`("id")
);
|
voter_2 | SELECT count(*) FROM VOTING_RECORD | Find the number of voting records in total. | 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 Voting_record (
StuID INTEGER,
Registration_Date VARCHAR(12),
Election_Cycle VARCHAR(12),
President_Vote INTEGER,
Vice_President_Vote INTEGER,
Secretary_Vote INTEGER,
Treasurer_Vote INTEGER,
Class_President_Vote INTEGER,
Class_Senator_Vote INTEGER,
FOREIGN KEY(StuID) REFERENCES Student(StuID),
FOREIGN KEY(President_Vote) REFERENCES Student(StuID),
FOREIGN KEY(Vice_President_Vote) REFERENCES Student(StuID),
FOREIGN KEY(Secretary_Vote) REFERENCES Student(StuID),
FOREIGN KEY(Treasurer_Vote) REFERENCES Student(StuID),
FOREIGN KEY(Class_President_Vote) REFERENCES Student(StuID),
FOREIGN KEY(Class_Senator_Vote) REFERENCES Student(StuID)
);
|
imdb | SELECT t4.title FROM CAST AS t5 JOIN actor AS t1 ON t5.aid = t1.aid JOIN movie AS t4 ON t4.mid = t5.msid JOIN directed_by AS t2 ON t4.mid = t2.msid JOIN director AS t3 ON t3.did = t2.did WHERE t1.name = "Taraneh Alidoosti" AND t3.name = "Asghar Farhadi"; | Find all movies directed by " Asghar Farhadi " and featuring " Taraneh Alidoosti " | CREATE TABLE "actor" (
"aid" int,
"gender" text,
"name" text,
"nationality" text,
"birth_city" text,
"birth_year" int,
primary key("aid")
);
CREATE TABLE "copyright" (
"id" int,
"msid" int,
"cid" int,
primary key("id")
);
CREATE TABLE "cast" (
"id" int,
"msid" int,
"aid" int,
"role" int,
primary key("id"),
foreign key("aid") references `actor`("aid"),
foreign key("msid") references `copyright`("msid")
);
CREATE TABLE "genre" (
"gid" int,
"genre" text,
primary key("gid")
);
CREATE TABLE "classification" (
"id" int,
"msid" int,
"gid" int,
primary key("id"),
foreign key("gid") references `genre`("gid"),
foreign key("msid") references `copyright`("msid")
);
CREATE TABLE "company" (
"id" int,
"name" text,
"country_code" text,
primary key("id")
);
CREATE TABLE "director" (
"did" int,
"gender" text,
"name" text,
"nationality" text,
"birth_city" text,
"birth_year" int,
primary key("did")
);
CREATE TABLE "producer" (
"pid" int,
"gender" text,
"name" text,
"nationality" text,
"birth_city" text,
"birth_year" int,
primary key("pid")
);
CREATE TABLE "directed_by" (
"id" int,
"msid" int,
"did" int,
primary key("id"),
foreign key("msid") references `copyright`("msid"),
foreign key("did") references `director`("did")
);
CREATE TABLE "keyword" (
"id" int,
"keyword" text,
primary key("id")
);
CREATE TABLE "made_by" (
"id" int,
"msid" int,
"pid" int,
primary key("id"),
foreign key("msid") references `copyright`("msid"),
foreign key("pid") references `producer`("pid")
);
CREATE TABLE "movie" (
"mid" int,
"title" text,
"release_year" int,
"title_aka" text,
"budget" text,
primary key("mid")
);
CREATE TABLE "tags" (
"id" int,
"msid" int,
"kid" int,
primary key("id"),
foreign key("msid") references `copyright`("msid"),
foreign key("kid") references `keyword`("kid")
);
CREATE TABLE "tv_series" (
"sid" int,
"title" text,
"release_year" int,
"num_of_seasons" int,
"num_of_episodes" int,
"title_aka" text,
"budget" text,
primary key("sid")
);
CREATE TABLE "writer" (
"wid" int,
"gender" text,
"name" int,
"nationality" int,
"num_of_episodes" int,
"birth_city" text,
"birth_year" int,
primary key("wid")
);
CREATE TABLE "written_by" (
"id" int,
"msid" int,
"wid" int,
foreign key("msid") references `copyright`("msid"),
foreign key("wid") references `writer`("wid")
);
|
music_2 | SELECT TYPE FROM vocals GROUP BY TYPE ORDER BY count(*) DESC LIMIT 1 | Which vocal type is the most frequently appearring type? | CREATE TABLE "Songs" (
"SongId" INTEGER PRIMARY KEY,
"Title" TEXT
);
CREATE TABLE "Albums" (
"AId" INTEGER PRIMARY KEY,
"Title" TEXT,
"Year" INTEGER,
"Label" TEXT,
"Type" TEXT );
CREATE TABLE "Band" (
"Id" INTEGER PRIMARY KEY,
"Firstname" TEXT,
"Lastname" TEXT );
CREATE TABLE "Instruments" (
"SongId" INTEGER,
"BandmateId" INTEGER,
"Instrument" TEXT ,
PRIMARY KEY(SongId, BandmateId, Instrument),
FOREIGN KEY (SongId) REFERENCES Songs(SongId),
FOREIGN KEY (BandmateId) REFERENCES Band(Id)
);
CREATE TABLE "Performance" (
"SongId" INTEGER,
"Bandmate" INTEGER,
"StagePosition" TEXT,
PRIMARY KEY(SongId, Bandmate),
FOREIGN KEY (SongId) REFERENCES Songs(SongId),
FOREIGN KEY (Bandmate) REFERENCES Band(Id)
);
CREATE TABLE "Tracklists" (
"AlbumId" INTEGER,
"Position" INTEGER,
"SongId" INTEGER ,
PRIMARY KEY(AlbumId, Position),
FOREIGN KEY (SongId) REFERENCES Songs(SongId),
FOREIGN KEY (AlbumId) REFERENCES Albums(AId)
);
CREATE TABLE "Vocals" (
"SongId" INTEGER,
"Bandmate" INTEGER,
"Type" TEXT,
PRIMARY KEY(SongId, Bandmate),
FOREIGN KEY (SongId) REFERENCES Songs(SongId),
FOREIGN KEY (Bandmate) REFERENCES Band(Id)
);
|
insurance_policies | SELECT Amount_Settled , Amount_Claimed FROM Claims ORDER BY Amount_Claimed DESC LIMIT 1 | Find the settlement amount of the claim with the largest claim amount. Show both the settlement amount and claim amount. | CREATE TABLE Customers (
Customer_ID INTEGER NOT NULL,
Customer_Details VARCHAR(255) NOT NULL,
PRIMARY KEY (Customer_ID)
);
CREATE TABLE Customer_Policies (
Policy_ID INTEGER NOT NULL,
Customer_ID INTEGER NOT NULL,
Policy_Type_Code CHAR(15) NOT NULL,
Start_Date DATE,
End_Date DATE,
PRIMARY KEY (Policy_ID),
FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID)
);
CREATE TABLE Claims (
Claim_ID INTEGER NOT NULL,
Policy_ID INTEGER NOT NULL,
Date_Claim_Made DATE,
Date_Claim_Settled DATE,
Amount_Claimed INTEGER,
Amount_Settled INTEGER,
PRIMARY KEY (Claim_ID),
FOREIGN KEY (Policy_ID) REFERENCES Customer_Policies (Policy_ID)
);
CREATE TABLE Settlements (
Settlement_ID INTEGER NOT NULL,
Claim_ID INTEGER NOT NULL,
Date_Claim_Made DATE,
Date_Claim_Settled DATE,
Amount_Claimed INTEGER,
Amount_Settled INTEGER,
Customer_Policy_ID INTEGER NOT NULL,
PRIMARY KEY (Settlement_ID),
FOREIGN KEY (Claim_ID) REFERENCES Claims (Claim_ID)
);
CREATE TABLE Payments (
Payment_ID INTEGER NOT NULL,
Settlement_ID INTEGER NOT NULL,
Payment_Method_Code VARCHAR(255),
Date_Payment_Made DATE,
Amount_Payment INTEGER,
PRIMARY KEY (Payment_ID),
FOREIGN KEY (Settlement_ID) REFERENCES Settlements (Settlement_ID)
);
|
hr_1 | SELECT * FROM employees WHERE salary BETWEEN 8000 AND 12000 AND commission_pct != "null" OR department_id != 40 | Return all information about employees with salaries between 8000 and 12000 for which commission is not null or where their department id is not 40. | CREATE TABLE IF NOT EXISTS `regions` (
`REGION_ID` decimal(5,0) NOT NULL,
`REGION_NAME` varchar(25) DEFAULT NULL,
PRIMARY KEY (`REGION_ID`)
);
CREATE TABLE IF NOT EXISTS `countries` (
`COUNTRY_ID` varchar(2) NOT NULL,
`COUNTRY_NAME` varchar(40) DEFAULT NULL,
`REGION_ID` decimal(10,0) DEFAULT NULL,
PRIMARY KEY (`COUNTRY_ID`),
FOREIGN KEY (`REGION_ID`) REFERENCES regions (`REGION_ID`)
);
CREATE TABLE IF NOT EXISTS `departments` (
`DEPARTMENT_ID` decimal(4,0) NOT NULL DEFAULT '0',
`DEPARTMENT_NAME` varchar(30) NOT NULL,
`MANAGER_ID` decimal(6,0) DEFAULT NULL,
`LOCATION_ID` decimal(4,0) DEFAULT NULL,
PRIMARY KEY (`DEPARTMENT_ID`)
);
CREATE TABLE IF NOT EXISTS `jobs` (
`JOB_ID` varchar(10) NOT NULL DEFAULT '',
`JOB_TITLE` varchar(35) NOT NULL,
`MIN_SALARY` decimal(6,0) DEFAULT NULL,
`MAX_SALARY` decimal(6,0) DEFAULT NULL,
PRIMARY KEY (`JOB_ID`)
);
CREATE TABLE IF NOT EXISTS `employees` (
`EMPLOYEE_ID` decimal(6,0) NOT NULL DEFAULT '0',
`FIRST_NAME` varchar(20) DEFAULT NULL,
`LAST_NAME` varchar(25) NOT NULL,
`EMAIL` varchar(25) NOT NULL,
`PHONE_NUMBER` varchar(20) DEFAULT NULL,
`HIRE_DATE` date NOT NULL,
`JOB_ID` varchar(10) NOT NULL,
`SALARY` decimal(8,2) DEFAULT NULL,
`COMMISSION_PCT` decimal(2,2) DEFAULT NULL,
`MANAGER_ID` decimal(6,0) DEFAULT NULL,
`DEPARTMENT_ID` decimal(4,0) DEFAULT NULL,
PRIMARY KEY (`EMPLOYEE_ID`),
FOREIGN KEY (`DEPARTMENT_ID`) REFERENCES departments(`DEPARTMENT_ID`),
FOREIGN KEY (`JOB_ID`) REFERENCES jobs(`JOB_ID`)
);
CREATE TABLE IF NOT EXISTS `job_history` (
`EMPLOYEE_ID` decimal(6,0) NOT NULL,
`START_DATE` date NOT NULL,
`END_DATE` date NOT NULL,
`JOB_ID` varchar(10) NOT NULL,
`DEPARTMENT_ID` decimal(4,0) DEFAULT NULL,
PRIMARY KEY (`EMPLOYEE_ID`,`START_DATE`),
FOREIGN KEY (`EMPLOYEE_ID`) REFERENCES employees(`EMPLOYEE_ID`),
FOREIGN KEY (`DEPARTMENT_ID`) REFERENCES departments(`DEPARTMENT_ID`),
FOREIGN KEY (`JOB_ID`) REFERENCES jobs(`JOB_ID`)
);
CREATE TABLE IF NOT EXISTS `locations` (
`LOCATION_ID` decimal(4,0) NOT NULL DEFAULT '0',
`STREET_ADDRESS` varchar(40) DEFAULT NULL,
`POSTAL_CODE` varchar(12) DEFAULT NULL,
`CITY` varchar(30) NOT NULL,
`STATE_PROVINCE` varchar(25) DEFAULT NULL,
`COUNTRY_ID` varchar(2) DEFAULT NULL,
PRIMARY KEY (`LOCATION_ID`),
FOREIGN KEY (`COUNTRY_ID`) REFERENCES countries(`COUNTRY_ID`)
);
|
college_3 | SELECT T3.Fname , T3.LName , T2.gradepoint FROM ENROLLED_IN AS T1 JOIN GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID | What are the full names and gradepoints for all enrollments? | 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 Faculty (
FacID INTEGER PRIMARY KEY,
Lname VARCHAR(15),
Fname VARCHAR(15),
Rank VARCHAR(15),
Sex VARCHAR(1),
Phone INTEGER,
Room VARCHAR(5),
Building VARCHAR(13)
);
create table Department (
DNO INTEGER PRIMARY KEY,
Division VARCHAR(2),
DName VARCHAR(25),
Room VARCHAR(5),
Building VARCHAR(13),
DPhone INTEGER
);
create table Member_of (
FacID INTEGER,
DNO INTEGER,
Appt_Type VARCHAR(15),
FOREIGN KEY(FacID) REFERENCES Faculty(FacID),
FOREIGN KEY(DNO) REFERENCES Department(DNO)
);
create table Course (
CID VARCHAR(7) PRIMARY KEY,
CName VARCHAR(40),
Credits INTEGER,
Instructor INTEGER,
Days VARCHAR(5),
Hours VARCHAR(11),
DNO INTEGER,
FOREIGN KEY(Instructor) REFERENCES Faculty(FacID),
FOREIGN KEY(DNO) REFERENCES Department(DNO)
);
create table Minor_in (
StuID INTEGER,
DNO INTEGER,
FOREIGN KEY(StuID) REFERENCES Student(StuID),
FOREIGN KEY(DNO) REFERENCES Department(DNO)
);
create table Enrolled_in (
StuID INTEGER,
CID VARCHAR(7),
Grade VARCHAR(2),
FOREIGN KEY(StuID) REFERENCES Student(StuID),
FOREIGN KEY(CID) REFERENCES Course(CID),
FOREIGN KEY(Grade) REFERENCES Gradeconversion(lettergrade)
);
create table Gradeconversion (
lettergrade VARCHAR(2) PRIMARY KEY,
gradepoint FLOAT
);
|
restaurants | SELECT t3.house_number , t1.name FROM restaurant AS t1 JOIN geographic AS t2 ON t1.city_name = t2.city_name JOIN LOCATION AS t3 ON t1.id = t3.restaurant_id WHERE t2.region = "yosemite and mono lake area" AND t1.food_type = "french" AND t1.rating > 2.5; | give me some restaurants good for french food in the yosemite and mono lake area ? | CREATE TABLE "GEOGRAPHIC" (
"CITY_NAME" text,
"COUNTY" text,
"REGION" text,
primary key("CITY_NAME")
);
CREATE TABLE "RESTAURANT" (
"ID" int,
"NAME" text,
"FOOD_TYPE" text,
"CITY_NAME" text,
"RATING" real,
primary key("ID"),
foreign key ("CITY_NAME") references `GEOGRAPHIC`("CITY_NAME")
);
CREATE TABLE "LOCATION" (
"RESTAURANT_ID" int,
"HOUSE_NUMBER" int,
"STREET_NAME" text,
"CITY_NAME" text,
primary key("RESTAURANT_ID"),
foreign key ("CITY_NAME") references `GEOGRAPHIC`("CITY_NAME")
foreign key ("RESTAURANT_ID") references `RESTAURANT`("RESTAURANT_ID")
);
|
voter_2 | SELECT DISTINCT T1.Fname , T1.LName FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = T2.VICE_President_VOTE WHERE T1.age = 18 | What are the first names and last names of the students who are 18 years old and have vice president votes. | 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 Voting_record (
StuID INTEGER,
Registration_Date VARCHAR(12),
Election_Cycle VARCHAR(12),
President_Vote INTEGER,
Vice_President_Vote INTEGER,
Secretary_Vote INTEGER,
Treasurer_Vote INTEGER,
Class_President_Vote INTEGER,
Class_Senator_Vote INTEGER,
FOREIGN KEY(StuID) REFERENCES Student(StuID),
FOREIGN KEY(President_Vote) REFERENCES Student(StuID),
FOREIGN KEY(Vice_President_Vote) REFERENCES Student(StuID),
FOREIGN KEY(Secretary_Vote) REFERENCES Student(StuID),
FOREIGN KEY(Treasurer_Vote) REFERENCES Student(StuID),
FOREIGN KEY(Class_President_Vote) REFERENCES Student(StuID),
FOREIGN KEY(Class_Senator_Vote) REFERENCES Student(StuID)
);
|
company_employee | SELECT Headquarters FROM company GROUP BY Headquarters HAVING COUNT(*) >= 2 | Show the headquarters that have at least two companies. | CREATE TABLE "people" (
"People_ID" int,
"Age" int,
"Name" text,
"Nationality" text,
"Graduation_College" text,
PRIMARY KEY ("People_ID")
);
CREATE TABLE "company" (
"Company_ID" real,
"Name" text,
"Headquarters" text,
"Industry" text,
"Sales_in_Billion" real,
"Profits_in_Billion" real,
"Assets_in_Billion" real,
"Market_Value_in_Billion" real,
PRIMARY KEY ("Company_ID")
);
CREATE TABLE "employment" (
"Company_ID" int,
"People_ID" int,
"Year_working" int,
PRIMARY KEY ("Company_ID","People_ID"),
FOREIGN KEY ("Company_ID") REFERENCES `company`("Company_ID"),
FOREIGN KEY ("People_ID") REFERENCES `people`("People_ID")
);
|
college_1 | SELECT T1.emp_fname , T2.prof_office FROM employee AS T1 JOIN professor AS T2 ON T1.emp_num = T2.emp_num JOIN department AS T3 ON T3.dept_code = T2.dept_code WHERE T3.dept_name = 'History' AND T2.prof_high_degree = 'Ph.D.' | Find the first name and office of the professor who is in the history department and has a Ph.D. degree. | null |
geo | SELECT highest_elevation FROM highlow WHERE state_name = "delaware"; | what is the highest elevation in delaware | CREATE TABLE `state` (
`state_name` text
, `population` integer DEFAULT NULL
, `area` double DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `capital` text
, `density` double DEFAULT NULL
, PRIMARY KEY (`state_name`)
);
CREATE TABLE `city` (
`city_name` text
, `population` integer DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `state_name` text
, PRIMARY KEY (`city_name`,`state_name`)
, FOREIGN KEY(`state_name`) REFERENCES `state`(`state_name`)
);
CREATE TABLE `border_info` (
`state_name` text
, `border` text
, PRIMARY KEY (`border`,`state_name`)
, FOREIGN KEY(`state_name`) REFERENCES `state`(`state_name`)
, FOREIGN KEY(`border`) REFERENCES `state`(`state_name`)
);
CREATE TABLE `highlow` (
`state_name` text
, `highest_elevation` text
, `lowest_point` text
, `highest_point` text
, `lowest_elevation` text
, PRIMARY KEY (`state_name`)
, FOREIGN KEY(`state_name`) REFERENCES `state`(`state_name`)
);
CREATE TABLE `lake` (
`lake_name` text
, `area` double DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `state_name` text
);
CREATE TABLE `mountain` (
`mountain_name` text
, `mountain_altitude` integer DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `state_name` text
, PRIMARY KEY (`mountain_name`, `state_name`)
, FOREIGN KEY(`state_name`) REFERENCES `state`(`state_name`)
);
CREATE TABLE `river` (
`river_name` text
, `length` integer DEFAULT NULL
, `country_name` varchar(3) NOT NULL DEFAULT ''
, `traverse` text
, PRIMARY KEY (`river_name`)
, FOREIGN KEY(`traverse`) REFERENCES `state`(`state_name`)
); |
store_1 | SELECT T1.name , COUNT(*) FROM genres AS T1 JOIN tracks AS T2 ON T2.genre_id = T1.id GROUP BY T1.id ORDER BY count(*) DESC LIMIT 5; | How many tracks does each genre have and what are the names of the top 5? | CREATE TABLE artists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
CREATE TABLE albums
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
FOREIGN KEY (artist_id) REFERENCES artists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
);
CREATE TABLE employees
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
FOREIGN KEY (reports_to) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
);
CREATE TABLE customers
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
FOREIGN KEY (support_rep_id) REFERENCES employees (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
);
CREATE TABLE genres
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
CREATE TABLE invoices
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10,2) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
);
CREATE TABLE media_types
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
CREATE TABLE tracks
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10,2) NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (genre_id) REFERENCES genres (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (media_type_id) REFERENCES media_types (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
);
CREATE TABLE invoice_lines
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10,2) NOT NULL,
quantity INTEGER NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
);
CREATE TABLE playlists
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(120)
);
CREATE TABLE playlist_tracks
(
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT PK_PlaylistTrack PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY (playlist_id) REFERENCES playlists (id)
ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (track_id) REFERENCES tracks (id)
ON DELETE NO ACTION ON UPDATE NO ACTION
);
|
student_assessment | SELECT T1.student_id , count(*) FROM students AS T1 JOIN student_course_registrations AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id | For every student who is registered for some course, how many courses are they registered for? | CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
line_1 VARCHAR(80),
line_2 VARCHAR(80),
city VARCHAR(50),
zip_postcode CHAR(20),
state_province_county VARCHAR(50),
country VARCHAR(50),
PRIMARY KEY (address_id)
);
CREATE TABLE People (
person_id INTEGER NOT NULL,
first_name VARCHAR(255),
middle_name VARCHAR(255),
last_name VARCHAR(255),
cell_mobile_number VARCHAR(40),
email_address VARCHAR(40),
login_name VARCHAR(40),
password VARCHAR(40),
PRIMARY KEY (person_id)
);
CREATE TABLE Students (
student_id INTEGER NOT NULL,
student_details VARCHAR(255),
PRIMARY KEY (student_id),
FOREIGN KEY (student_id) REFERENCES People (person_id)
);
CREATE TABLE Courses (
course_id VARCHAR(100) NOT NULL,
course_name VARCHAR(120),
course_description VARCHAR(255),
other_details VARCHAR(255),
PRIMARY KEY (course_id)
);
CREATE TABLE People_Addresses (
person_address_id INTEGER NOT NULL,
person_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
date_from DATETIME,
date_to DATETIME,
PRIMARY KEY (person_address_id),
FOREIGN KEY (person_id) REFERENCES People (person_id),
FOREIGN KEY (address_id) REFERENCES Addresses (address_id)
);
CREATE TABLE Student_Course_Registrations (
student_id INTEGER NOT NULL,
course_id INTEGER NOT NULL,
registration_date DATETIME NOT NULL,
PRIMARY KEY (student_id, course_id),
FOREIGN KEY (student_id) REFERENCES Students (student_id),
FOREIGN KEY (course_id) REFERENCES Courses (course_id)
);
CREATE TABLE Student_Course_Attendance (
student_id INTEGER NOT NULL,
course_id INTEGER NOT NULL,
date_of_attendance DATETIME NOT NULL,
PRIMARY KEY (student_id, course_id),
FOREIGN KEY (student_id, course_id) REFERENCES Student_Course_Registrations (student_id,course_id)
);
CREATE TABLE Candidates (
candidate_id INTEGER NOT NULL ,
candidate_details VARCHAR(255),
PRIMARY KEY (candidate_id),
FOREIGN KEY (candidate_id) REFERENCES People (person_id)
);
CREATE TABLE Candidate_Assessments (
candidate_id INTEGER NOT NULL,
qualification CHAR(15) NOT NULL,
assessment_date DATETIME NOT NULL,
asessment_outcome_code CHAR(15) NOT NULL,
PRIMARY KEY (candidate_id, qualification),
FOREIGN KEY (candidate_id) REFERENCES Candidates (candidate_id)
);
|
scholar | SELECT DISTINCT t3.paperid FROM writes AS t3 JOIN author AS t2 ON t3.authorid = t2.authorid JOIN writes AS t4 ON t4.paperid = t3.paperid JOIN author AS t1 ON t4.authorid = t1.authorid WHERE t2.authorname = "Peter Mertens" AND t1.authorname = "Dina Barbian"; | Which papers have Peter Mertens and Dina Barbian as co-authors ? | CREATE TABLE `venue` (
`venueId` integer NOT NULL
, `venueName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`venueId`)
);
CREATE TABLE `author` (
`authorId` integer NOT NULL
, `authorName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`authorId`)
);
CREATE TABLE `dataset` (
`datasetId` integer NOT NULL
, `datasetName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`datasetId`)
);
CREATE TABLE `journal` (
`journalId` integer NOT NULL
, `journalName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`journalId`)
);
CREATE TABLE `keyphrase` (
`keyphraseId` integer NOT NULL
, `keyphraseName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`keyphraseId`)
);
CREATE TABLE `paper` (
`paperId` integer NOT NULL
, `title` varchar(300) DEFAULT NULL
, `venueId` integer DEFAULT NULL
, `year` integer DEFAULT NULL
, `numCiting` integer DEFAULT NULL
, `numCitedBy` integer DEFAULT NULL
, `journalId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`)
, FOREIGN KEY(`journalId`) REFERENCES `journal`(`journalId`)
, FOREIGN KEY(`venueId`) REFERENCES `venue`(`venueId`)
);
CREATE TABLE `cite` (
`citingPaperId` integer NOT NULL
, `citedPaperId` integer NOT NULL
, PRIMARY KEY (`citingPaperId`,`citedPaperId`)
, FOREIGN KEY(`citedpaperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`citingpaperId`) REFERENCES `paper`(`paperId`)
);
CREATE TABLE `paperDataset` (
`paperId` integer DEFAULT NULL
, `datasetId` integer DEFAULT NULL
, PRIMARY KEY (`datasetId`, `paperId`)
);
CREATE TABLE `paperKeyphrase` (
`paperId` integer DEFAULT NULL
, `keyphraseId` integer DEFAULT NULL
, PRIMARY KEY (`keyphraseId`,`paperId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`keyphraseId`) REFERENCES `keyphrase`(`keyphraseId`)
);
CREATE TABLE `writes` (
`paperId` integer DEFAULT NULL
, `authorId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`,`authorId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`authorId`) REFERENCES `author`(`authorId`)
);
|
flight_4 | SELECT country FROM airlines GROUP BY country ORDER BY count(*) DESC LIMIT 1 | Which countries has the most number of airlines? | null |
tracking_orders | SELECT DISTINCT invoice_details FROM invoices WHERE invoice_date < "1989-09-03" OR invoice_date > "2007-12-25" | Find the distinct details of invoices which are created before 1989-09-03 or after 2007-12-25. | CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_name` VARCHAR(80),
`customer_details` VARCHAR(255)
);
CREATE TABLE `Invoices` (
`invoice_number` INTEGER PRIMARY KEY,
`invoice_date` DATETIME,
`invoice_details` VARCHAR(255)
);
CREATE TABLE `Orders` (
`order_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`order_status` VARCHAR(10) NOT NULL,
`date_order_placed` DATETIME NOT NULL,
`order_details` VARCHAR(255),
FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` )
);
CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`product_name` VARCHAR(80),
`product_details` VARCHAR(255)
);
CREATE TABLE `Order_Items` (
`order_item_id` INTEGER PRIMARY KEY,
`product_id` INTEGER NOT NULL,
`order_id` INTEGER NOT NULL,
`order_item_status` VARCHAR(10) NOT NULL,
`order_item_details` VARCHAR(255),
FOREIGN KEY (`order_id` ) REFERENCES `Orders`(`order_id` ),
FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` )
);
CREATE TABLE `Shipments` (
`shipment_id` INTEGER PRIMARY KEY,
`order_id` INTEGER NOT NULL,
`invoice_number` INTEGER NOT NULL,
`shipment_tracking_number` VARCHAR(80),
`shipment_date` DATETIME,
`other_shipment_details` VARCHAR(255),
FOREIGN KEY (`order_id` ) REFERENCES `Orders`(`order_id` ),
FOREIGN KEY (`invoice_number` ) REFERENCES `Invoices`(`invoice_number` )
);
CREATE TABLE `Shipment_Items` (
`shipment_id` INTEGER NOT NULL,
`order_item_id` INTEGER NOT NULL,
FOREIGN KEY (`order_item_id` ) REFERENCES `Order_Items`(`order_item_id` ),
FOREIGN KEY (`shipment_id` ) REFERENCES `Shipments`(`shipment_id` )
);
|
allergy_1 | SELECT DISTINCT Major FROM Student | Show all majors. | create table Allergy_Type (
Allergy VARCHAR(20) PRIMARY KEY,
AllergyType VARCHAR(20)
);
create table Has_Allergy (
StuID INTEGER,
Allergy VARCHAR(20),
FOREIGN KEY(StuID) REFERENCES Student(StuID),
FOREIGN KEY(Allergy) REFERENCES Allergy_Type(Allergy)
);
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)
);
|
cre_Theme_park | SELECT DISTINCT Location_Name FROM LOCATIONS | What are the distinct location names? | CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);
CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);
CREATE TABLE Ref_Attraction_Types (
Attraction_Type_Code CHAR(15) NOT NULL,
Attraction_Type_Description VARCHAR(255),
PRIMARY KEY (Attraction_Type_Code),
UNIQUE (Attraction_Type_Code)
);
CREATE TABLE Visitors (
Tourist_ID INTEGER NOT NULL,
Tourist_Details VARCHAR(255),
PRIMARY KEY (Tourist_ID),
UNIQUE (Tourist_ID)
);
CREATE TABLE Features (
Feature_ID INTEGER NOT NULL,
Feature_Details VARCHAR(255),
PRIMARY KEY (Feature_ID)
);
CREATE TABLE Hotels (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range real,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code)
);
CREATE TABLE Tourist_Attractions (
Tourist_Attraction_ID INTEGER NOT NULL,
Attraction_Type_Code CHAR(15) NOT NULL,
Location_ID INTEGER NOT NULL,
How_to_Get_There VARCHAR(255),
Name VARCHAR(255),
Description VARCHAR(255),
Opening_Hours VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Tourist_Attraction_ID),
FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID),
FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code)
);
CREATE TABLE Street_Markets (
Market_ID INTEGER NOT NULL,
Market_Details VARCHAR(255),
PRIMARY KEY (Market_ID),
FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Shops (
Shop_ID INTEGER NOT NULL,
Shop_Details VARCHAR(255),
PRIMARY KEY (Shop_ID),
FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Museums (
Museum_ID INTEGER NOT NULL,
Museum_Details VARCHAR(255),
PRIMARY KEY (Museum_ID),
FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Royal_Family (
Royal_Family_ID INTEGER NOT NULL,
Royal_Family_Details VARCHAR(255),
PRIMARY KEY (Royal_Family_ID),
FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Theme_Parks (
Theme_Park_ID INTEGER NOT NULL,
Theme_Park_Details VARCHAR(255),
PRIMARY KEY (Theme_Park_ID),
FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Visits (
Visit_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Tourist_ID INTEGER NOT NULL,
Visit_Date DATETIME NOT NULL,
Visit_Details VARCHAR(40) NOT NULL,
PRIMARY KEY (Visit_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID)
);
CREATE TABLE Photos (
Photo_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(255),
Description VARCHAR(255),
Filename VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Photo_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Staff (
Staff_ID INTEGER NOT NULL,
Tourist_Attraction_ID INTEGER NOT NULL,
Name VARCHAR(40),
Other_Details VARCHAR(255),
PRIMARY KEY (Staff_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID)
);
CREATE TABLE Tourist_Attraction_Features (
Tourist_Attraction_ID INTEGER NOT NULL,
Feature_ID INTEGER NOT NULL,
PRIMARY KEY (Tourist_Attraction_ID, Feature_ID),
FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID),
FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID)
);
|
inn_1 | SELECT count(*) FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId WHERE T2.maxOccupancy = T1.Adults + T1.Kids; | How many times the number of adults and kids staying in a room reached the maximum capacity of the room? | null |
academic | SELECT COUNT ( DISTINCT name ) FROM organization WHERE continent = "North America"; | return me the number of the organizations in " North America " . | CREATE TABLE "author" (
"aid" int,
"homepage" text,
"name" text,
"oid" int,
primary key("aid")
);
CREATE TABLE "conference" (
"cid" int,
"homepage" text,
"name" text,
primary key ("cid")
);
CREATE TABLE "domain" (
"did" int,
"name" text,
primary key ("did")
);
CREATE TABLE "domain_author" (
"aid" int,
"did" int,
primary key ("did", "aid"),
foreign key("aid") references `author`("aid"),
foreign key("did") references `domain`("did")
);
CREATE TABLE "domain_conference" (
"cid" int,
"did" int,
primary key ("did", "cid"),
foreign key("cid") references `conference`("cid"),
foreign key("did") references `domain`("did")
);
CREATE TABLE "journal" (
"homepage" text,
"jid" int,
"name" text,
primary key("jid")
);
CREATE TABLE "domain_journal" (
"did" int,
"jid" int,
primary key ("did", "jid"),
foreign key("jid") references "journal"("jid"),
foreign key("did") references "domain"("did")
);
CREATE TABLE "keyword" (
"keyword" text,
"kid" int,
primary key("kid")
);
CREATE TABLE "domain_keyword" (
"did" int,
"kid" int,
primary key ("did", "kid"),
foreign key("kid") references "keyword"("kid"),
foreign key("did") references "domain"("did")
);
CREATE TABLE "publication" (
"abstract" text,
"cid" text,
"citation_num" int,
"jid" int,
"pid" int,
"reference_num" int,
"title" text,
"year" int,
primary key("pid"),
foreign key("jid") references "journal"("jid"),
foreign key("cid") references "conference"("cid")
);
CREATE TABLE "domain_publication" (
"did" int,
"pid" int,
primary key ("did", "pid"),
foreign key("pid") references "publication"("pid"),
foreign key("did") references "domain"("did")
);
CREATE TABLE "organization" (
"continent" text,
"homepage" text,
"name" text,
"oid" int,
primary key("oid")
);
CREATE TABLE "publication_keyword" (
"pid" int,
"kid" int,
primary key ("kid", "pid"),
foreign key("pid") references "publication"("pid"),
foreign key("kid") references "keyword"("kid")
);
CREATE TABLE "writes" (
"aid" int,
"pid" int,
primary key ("aid", "pid"),
foreign key("pid") references "publication"("pid"),
foreign key("aid") references "author"("aid")
);
CREATE TABLE "cite" (
"cited" int,
"citing" int,
foreign key("cited") references "publication"("pid"),
foreign key("citing") references "publication"("pid")
);
|
activity_1 | SELECT lname FROM faculty WHERE rank = 'Professor' EXCEPT SELECT DISTINCT T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID JOIN activity AS T3 ON T2.actid = T2.actid WHERE T3.activity_name = 'Canoeing' OR T3.activity_name = 'Kayaking' | Find the first names of professors who are not playing Canoeing or Kayaking. | create table Activity (
actid INTEGER PRIMARY KEY,
activity_name varchar(25)
);
create table Participates_in (
stuid INTEGER,
actid INTEGER,
FOREIGN KEY(stuid) REFERENCES Student(StuID),
FOREIGN KEY(actid) REFERENCES Activity(actid)
);
create table Faculty_Participates_in (
FacID INTEGER,
actid INTEGER,
FOREIGN KEY(FacID) REFERENCES Faculty(FacID),
FOREIGN KEY(actid) REFERENCES Activity(actid)
);
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 Faculty (
FacID INTEGER PRIMARY KEY,
Lname VARCHAR(15),
Fname VARCHAR(15),
Rank VARCHAR(15),
Sex VARCHAR(1),
Phone INTEGER,
Room VARCHAR(5),
Building VARCHAR(13)
);
|
dorm_1 | SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T1.amenid = T2.amenid GROUP BY T2.amenid ORDER BY count(*) DESC LIMIT 1 | What is the most common amenity 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 (
dormid INTEGER,
dorm_name VARCHAR(20),
student_capacity INTEGER,
gender VARCHAR(1)
) ;
create table Dorm_amenity (
amenid INTEGER,
amenity_name VARCHAR(25)
) ;
create table Has_amenity (
dormid INTEGER,
amenid INTEGER,
FOREIGN KEY (dormid) REFERENCES `Dorm`(dormid),
FOREIGN KEY (amenid) REFERENCES `Dorm_amenity`(amenid)
);
create table Lives_in (
stuid INTEGER,
dormid INTEGER,
room_number INTEGER,
FOREIGN KEY (stuid) REFERENCES `Student`(StuID),
FOREIGN KEY (dormid) REFERENCES `Dorm`(dormid)
);
|
cre_Drama_Workshop_Groups | SELECT T1.State_County FROM Addresses AS T1 JOIN Stores AS T2 ON T1.Address_ID = T2.Address_ID WHERE T2.Marketing_Region_Code = "CA" | Find the states or counties where the stores with marketing region code "CA" are located. | CREATE TABLE Ref_Payment_Methods (
payment_method_code CHAR(10) NOT NULL,
payment_method_description VARCHAR(80),
PRIMARY KEY (payment_method_code),
UNIQUE (payment_method_code)
);
CREATE TABLE Ref_Service_Types (
Service_Type_Code CHAR(15) NOT NULL,
Parent_Service_Type_Code CHAR(15),
Service_Type_Description VARCHAR(255),
PRIMARY KEY (Service_Type_Code),
UNIQUE (Service_Type_Code)
);
CREATE TABLE Addresses (
Address_ID VARCHAR(100) NOT NULL,
Line_1 VARCHAR(255),
Line_2 VARCHAR(255),
City_Town VARCHAR(255),
State_County VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Address_ID),
UNIQUE (Address_ID)
);
CREATE TABLE Products (
Product_ID VARCHAR(100) NOT NULL,
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
Product_Description VARCHAR(255),
Other_Product_Service_Details VARCHAR(255),
PRIMARY KEY (Product_ID),
UNIQUE (Product_ID)
);
CREATE TABLE Marketing_Regions (
Marketing_Region_Code CHAR(15) NOT NULL,
Marketing_Region_Name VARCHAR(255) NOT NULL,
Marketing_Region_Descriptrion VARCHAR(255) NOT NULL,
Other_Details VARCHAR(255),
PRIMARY KEY (Marketing_Region_Code),
UNIQUE (Marketing_Region_Code)
);
CREATE TABLE Clients (
Client_ID INTEGER NOT NULL,
Address_ID INTEGER NOT NULL,
Customer_Email_Address VARCHAR(255),
Customer_Name VARCHAR(255),
Customer_Phone VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Client_ID),
UNIQUE (Client_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID)
);
CREATE TABLE Drama_Workshop_Groups (
Workshop_Group_ID INTEGER NOT NULL,
Address_ID INTEGER NOT NULL,
Currency_Code CHAR(15) NOT NULL,
Marketing_Region_Code CHAR(15) NOT NULL,
Store_Name VARCHAR(255),
Store_Phone VARCHAR(255),
Store_Email_Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Workshop_Group_ID),
UNIQUE (Workshop_Group_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID)
);
CREATE TABLE Performers (
Performer_ID INTEGER NOT NULL,
Address_ID INTEGER NOT NULL,
Customer_Name VARCHAR(255),
Customer_Phone VARCHAR(255),
Customer_Email_Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Performer_ID),
UNIQUE (Performer_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID)
);
CREATE TABLE Customers (
Customer_ID VARCHAR(100) NOT NULL,
Address_ID INTEGER NOT NULL,
Customer_Name VARCHAR(255),
Customer_Phone VARCHAR(255),
Customer_Email_Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Customer_ID),
UNIQUE (Customer_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID)
);
CREATE TABLE Stores (
Store_ID VARCHAR(100) NOT NULL,
Address_ID INTEGER NOT NULL,
Marketing_Region_Code CHAR(15) NOT NULL,
Store_Name VARCHAR(255),
Store_Phone VARCHAR(255),
Store_Email_Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Store_ID),
UNIQUE (Store_ID),
FOREIGN KEY (Address_ID) REFERENCES Addresses (Address_ID),
FOREIGN KEY (Marketing_Region_Code) REFERENCES Marketing_Regions (Marketing_Region_Code)
);
CREATE TABLE Bookings (
Booking_ID INTEGER NOT NULL ,
Customer_ID INTEGER NOT NULL,
Workshop_Group_ID VARCHAR(100) NOT NULL,
Status_Code CHAR(15) NOT NULL,
Store_ID INTEGER NOT NULL,
Order_Date DATETIME NOT NULL,
Planned_Delivery_Date DATETIME NOT NULL,
Actual_Delivery_Date DATETIME NOT NULL,
Other_Order_Details VARCHAR(255),
PRIMARY KEY (Booking_ID),
UNIQUE (Booking_ID),
FOREIGN KEY (Customer_ID) REFERENCES Clients (Client_ID),
FOREIGN KEY (Workshop_Group_ID) REFERENCES Drama_Workshop_Groups (Workshop_Group_ID)
);
CREATE TABLE Performers_in_Bookings (
Order_ID INTEGER NOT NULL,
Performer_ID INTEGER NOT NULL,
PRIMARY KEY (Order_ID, Performer_ID),
FOREIGN KEY (Performer_ID) REFERENCES Performers (Performer_ID),
FOREIGN KEY (Order_ID) REFERENCES Bookings (Booking_ID)
);
CREATE TABLE Customer_Orders (
Order_ID INTEGER NOT NULL ,
Customer_ID INTEGER NOT NULL,
Store_ID INTEGER NOT NULL,
Order_Date DATETIME NOT NULL,
Planned_Delivery_Date DATETIME NOT NULL,
Actual_Delivery_Date DATETIME NOT NULL,
Other_Order_Details VARCHAR(255),
PRIMARY KEY (Order_ID),
UNIQUE (Order_ID),
FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID),
FOREIGN KEY (Store_ID) REFERENCES Stores (Store_ID)
);
CREATE TABLE Order_Items (
Order_Item_ID INTEGER NOT NULL ,
Order_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
Order_Quantity VARCHAR(288),
Other_Item_Details VARCHAR(255),
PRIMARY KEY (Order_Item_ID),
FOREIGN KEY (Order_ID) REFERENCES Customer_Orders (Order_ID),
FOREIGN KEY (Product_ID) REFERENCES Products (Product_ID)
);
CREATE TABLE Invoices (
Invoice_ID INTEGER NOT NULL,
Order_ID INTEGER NOT NULL,
payment_method_code CHAR(15),
Product_ID INTEGER NOT NULL,
Order_Quantity VARCHAR(288),
Other_Item_Details VARCHAR(255),
Order_Item_ID INTEGER NOT NULL,
PRIMARY KEY (Invoice_ID),
FOREIGN KEY (Order_ID) REFERENCES Customer_Orders (Order_ID),
FOREIGN KEY (Order_ID) REFERENCES Bookings (Booking_ID),
FOREIGN KEY (payment_method_code) REFERENCES Ref_Payment_Methods (payment_method_code)
);
CREATE TABLE Services (
Service_ID INTEGER NOT NULL,
Service_Type_Code CHAR(15),
Workshop_Group_ID INTEGER NOT NULL,
Product_Description VARCHAR(255),
Product_Name VARCHAR(255),
Product_Price DECIMAL(20,4),
Other_Product_Service_Details VARCHAR(255),
PRIMARY KEY (Service_ID),
UNIQUE (Service_ID),
FOREIGN KEY (Workshop_Group_ID) REFERENCES Drama_Workshop_Groups (Workshop_Group_ID),
FOREIGN KEY (Service_Type_Code) REFERENCES Ref_Service_Types (Service_Type_Code)
);
CREATE TABLE Bookings_Services (
Order_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
PRIMARY KEY (Order_ID, Product_ID),
FOREIGN KEY (Order_ID) REFERENCES Bookings (Booking_ID),
FOREIGN KEY (Product_ID) REFERENCES Services (Service_ID)
);
CREATE TABLE Invoice_Items (
Invoice_Item_ID INTEGER NOT NULL ,
Invoice_ID INTEGER NOT NULL,
Order_ID INTEGER NOT NULL,
Order_Item_ID INTEGER NOT NULL,
Product_ID INTEGER NOT NULL,
Order_Quantity INTEGER,
Other_Item_Details VARCHAR(255),
PRIMARY KEY (Invoice_Item_ID),
FOREIGN KEY (Order_Item_ID) REFERENCES Order_Items (Order_Item_ID),
FOREIGN KEY (Invoice_ID) REFERENCES Invoices (Invoice_ID),
FOREIGN KEY (Order_ID, Product_ID) REFERENCES Bookings_Services (Order_ID,Product_ID)
);
|
gas_company | SELECT LOCATION , count(*) FROM gas_station GROUP BY LOCATION ORDER BY count(*) | For each location, how many gas stations are there in order? | CREATE TABLE "company" (
"Company_ID" int,
"Rank" int,
"Company" text,
"Headquarters" text,
"Main_Industry" text,
"Sales_billion" real,
"Profits_billion" real,
"Assets_billion" real,
"Market_Value" real,
PRIMARY KEY ("Company_ID")
);
CREATE TABLE "gas_station" (
"Station_ID" int,
"Open_Year" int,
"Location" text,
"Manager_Name" text,
"Vice_Manager_Name" text,
"Representative_Name" text,
PRIMARY KEY ("Station_ID")
);
CREATE TABLE "station_company" (
"Station_ID" int,
"Company_ID" int,
"Rank_of_the_Year" int,
PRIMARY KEY ("Station_ID","Company_ID"),
FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`),
FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`)
);
|
flight_4 | SELECT avg(elevation) , country FROM airports GROUP BY country | For each country, what is the average elevation of that country's airports? | null |
scholar | SELECT DISTINCT t3.paperid FROM paperdataset AS t2 JOIN dataset AS t1 ON t2.datasetid = t1.datasetid JOIN paper AS t3 ON t3.paperid = t2.paperid WHERE t1.datasetname = "WebKB"; | papers using WebKB | CREATE TABLE `venue` (
`venueId` integer NOT NULL
, `venueName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`venueId`)
);
CREATE TABLE `author` (
`authorId` integer NOT NULL
, `authorName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`authorId`)
);
CREATE TABLE `dataset` (
`datasetId` integer NOT NULL
, `datasetName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`datasetId`)
);
CREATE TABLE `journal` (
`journalId` integer NOT NULL
, `journalName` varchar(100) DEFAULT NULL
, PRIMARY KEY (`journalId`)
);
CREATE TABLE `keyphrase` (
`keyphraseId` integer NOT NULL
, `keyphraseName` varchar(50) DEFAULT NULL
, PRIMARY KEY (`keyphraseId`)
);
CREATE TABLE `paper` (
`paperId` integer NOT NULL
, `title` varchar(300) DEFAULT NULL
, `venueId` integer DEFAULT NULL
, `year` integer DEFAULT NULL
, `numCiting` integer DEFAULT NULL
, `numCitedBy` integer DEFAULT NULL
, `journalId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`)
, FOREIGN KEY(`journalId`) REFERENCES `journal`(`journalId`)
, FOREIGN KEY(`venueId`) REFERENCES `venue`(`venueId`)
);
CREATE TABLE `cite` (
`citingPaperId` integer NOT NULL
, `citedPaperId` integer NOT NULL
, PRIMARY KEY (`citingPaperId`,`citedPaperId`)
, FOREIGN KEY(`citedpaperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`citingpaperId`) REFERENCES `paper`(`paperId`)
);
CREATE TABLE `paperDataset` (
`paperId` integer DEFAULT NULL
, `datasetId` integer DEFAULT NULL
, PRIMARY KEY (`datasetId`, `paperId`)
);
CREATE TABLE `paperKeyphrase` (
`paperId` integer DEFAULT NULL
, `keyphraseId` integer DEFAULT NULL
, PRIMARY KEY (`keyphraseId`,`paperId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`keyphraseId`) REFERENCES `keyphrase`(`keyphraseId`)
);
CREATE TABLE `writes` (
`paperId` integer DEFAULT NULL
, `authorId` integer DEFAULT NULL
, PRIMARY KEY (`paperId`,`authorId`)
, FOREIGN KEY(`paperId`) REFERENCES `paper`(`paperId`)
, FOREIGN KEY(`authorId`) REFERENCES `author`(`authorId`)
);
|
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 232