db_id stringlengths 4 28 | question stringlengths 24 325 | evidence stringlengths 0 673 | SQL stringlengths 23 804 | schema stringlengths 352 37.3k |
|---|---|---|---|---|
food_inspection_2 | How many "food maintenance" related violations did inspection no.1454071 have? | "food maintenance" related refers to category = 'Food Maintenance'; inspection no.1454071 refers to inspection_id = '1454071' | SELECT COUNT(T2.point_id) FROM inspection_point AS T1 INNER JOIN violation AS T2 ON T1.point_id = T2.point_id WHERE T2.inspection_id = '1454071' AND T1.category = 'Food Maintenance' | CREATE TABLE employee
(
employee_id INTEGER
primary key,
first_name TEXT,
last_name TEXT,
address TEXT,
city TEXT,
state TEXT,
zip INTEGER,
phone TEXT,
title TEXT,
salary INTEGER,
supervisor INTEGER,
foreign key (s... |
beer_factory | What is the amount difference between the bottles of root beer sold from Louisiana and Missouri? | difference = SUBTRACT(COUNT(ContainerType = 'Bottle' WHERE State = 'LA'), COUNT(ContainerType = 'Bottle' State = 'MO')); bottles refers to ContainerType = 'Bottle'; Louisiana refers to State = 'LA'; Missouri refers to State = 'MO'; | SELECT ( SELECT COUNT(T1.BrandID) FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID WHERE T2.State = 'LA' AND T1.ContainerType = 'Bottle' ) - ( SELECT COUNT(T3.BrandID) FROM rootbeer AS T3 INNER JOIN rootbeerbrand AS T4 ON T3.BrandID = T4.BrandID WHERE T4.State = 'MO' AND T3.ContainerType = ... | CREATE TABLE customers
(
CustomerID INTEGER
primary key,
First TEXT,
Last TEXT,
StreetAddress TEXT,
City TEXT,
State TEXT,
ZipCode INTEGER,
Email TEXT,
Phone... |
books | For the publisher which published the most books, show its name. | published the most books refers to Max(Count(book_id)); publisher refers to publisher_name | SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id GROUP BY T2.publisher_name ORDER BY COUNT(T2.publisher_id) DESC LIMIT 1 | CREATE TABLE address_status
(
status_id INTEGER
primary key,
address_status TEXT
);
CREATE TABLE author
(
author_id INTEGER
primary key,
author_name TEXT
);
CREATE TABLE book_language
(
language_id INTEGER
primary key,
language_code TEXT,
language... |
regional_sales | Calculate the average monthly order and percentage of warehouse "WARE-NMK1003" in 2019. Among them, mention number of orders for floor lamps. | "WARE-NMK1003" is the WarehouseCode; in 2019 refers to SUBSTR(OrderDate, -2) = '19'; average = Divide (Count (OrderNumber where SUBSTR(OrderDate, -2) = '19'), 12); Percentage = Divide (Count(OrderNumber where WarehouseCode = 'WARE-NMK1003'), Count(OrderNumber)) * 100; 'Floor Lamps' is the Product Name; number of orders... | SELECT CAST(SUM(CASE WHEN T2.WarehouseCode = 'WARE-NMK1003' THEN 1 ELSE 0 END) AS REAL) / 12 , CAST(SUM(CASE WHEN T2.WarehouseCode = 'WARE-NMK1003' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.OrderNumber), COUNT(CASE WHEN T1.`Product Name` = 'Floor Lamps' AND T2.WarehouseCode = 'WARE-NMK1003' THEN T2.`Order Quantity` ... | CREATE TABLE Customers
(
CustomerID INTEGER
constraint Customers_pk
primary key,
"Customer Names" TEXT
);
CREATE TABLE Products
(
ProductID INTEGER
constraint Products_pk
primary key,
"Product Name" TEXT
);
CREATE TABLE Regions
(
StateCode TEXT
... |
video_games | What genres are the games published by 'Agatsuma Entertainment'? | genres refers to genre_name; 'Agatsuma Entertainment' refers to publisher_name = 'Agatsuma Entertainment'; | SELECT T4.genre_name FROM publisher AS T1 INNER JOIN game_publisher AS T2 ON T1.id = T2.publisher_id INNER JOIN game AS T3 ON T2.game_id = T3.id INNER JOIN genre AS T4 ON T3.genre_id = T4.id WHERE T1.publisher_name = 'Agatsuma Entertainment' | CREATE TABLE genre
(
id INTEGER not null
primary key,
genre_name TEXT default NULL
);
CREATE TABLE game
(
id INTEGER not null
primary key,
genre_id INTEGER default NULL,
game_name TEXT default NULL,
foreign key (genre_id) references genre(id)
);
C... |
shooting | What is the proportion of white males and females in the police force? | white refers to race = 'W'; male refers to gender = 'M'; female refers to gender = 'F'; proportion of white males = divide(count(officers where race = 'W' and gender = 'M'), count(officers)) * 100%; proportion of white females = divide(count(officers where race = 'W' and gender = 'F'), count(officers)) * 100% | SELECT CAST(SUM(gender = 'M') AS REAL) / SUM(gender = 'F') FROM officers WHERE race = 'W' | CREATE TABLE incidents
(
case_number TEXT not null
primary key,
date DATE not null,
location TEXT not null,
subject_statuses TEXT not null,
subject_weapon TEXT not null,
subjects T... |
college_completion | Give the web site address for the school in "PA" state with the highest latitude. | web site address refers to site; PA refers to state_abbr = 'PA'; highest latitude refers to MAX(lat_y); | SELECT DISTINCT T1.site FROM institution_details AS T1 INNER JOIN state_sector_grads AS T2 ON T2.state = T1.state WHERE T2.state_abbr = 'PA' AND T1.lat_y = ( SELECT MAX(T1.lat_y) FROM institution_details AS T1 INNER JOIN state_sector_grads AS T2 ON T2.state = T1.state WHERE T2.state_abbr = 'PA' ) | CREATE TABLE institution_details
(
unitid INTEGER
constraint institution_details_pk
primary key,
chronname TEXT,
city TEXT,
state TEXT,
level ... |
movie_3 | Write down the email addresses of active customers who rented between 5/25/2005 at 7:37:47 PM and 5/26/2005 at 10:06:49 AM. | email address refers to email; active refers to active = 1; between 5/25/2005 at 7:37:47 PM and 5/26/2005 at 10:06:49 AM refers to rental_date between '2005-5-25 07:37:47' and '2005-5-26 10:06:49' | SELECT T2.email FROM rental AS T1 INNER JOIN customer AS T2 ON T1.customer_id = T2.customer_id WHERE T1.rental_date BETWEEN '2005-5-25 07:37:47' AND '2005-5-26 10:06:49' AND T2.active = 1 | CREATE TABLE film_text
(
film_id INTEGER not null
primary key,
title TEXT not null,
description TEXT null
);
CREATE TABLE IF NOT EXISTS "actor"
(
actor_id INTEGER
primary key autoincrement,
first_name TEXT not null,
last_nam... |
retail_world | How old was the oldest employee at the time he or she was hired? | oldest employee at the time he or she was hired refers to MAX(SUBTRACT(HireDate, Birthdate)) | SELECT MAX(TIMESTAMPDIFF(YEAR, BirthDate, HireDate)) FROM Employees | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE Categories
(
CategoryID INTEGER PRIMARY KEY AUTOINCREMENT,
CategoryName TEXT,
Description TEXT
);
CREATE TABLE Customers
(
CustomerID INTEGER PRIMARY KEY AUTOINCREMENT,
CustomerName TEXT,
ContactName TEXT,
Address TEXT,
City TEXT,
... |
law_episode | How many episodes did J.K. Simmons' role appear on the show? | SELECT COUNT(T1.role) FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T2.name = 'J.K. Simmons' | CREATE TABLE Episode
(
episode_id TEXT
primary key,
series TEXT,
season INTEGER,
episode INTEGER,
number_in_series INTEGER,
title TEXT,
summary TEXT,
air_date DATE,
episode_image TEXT,
rating ... | |
sales | What is the total cost of all the "Road-650, Red, 60" products that Abraham E. Bennet sold? | total cost = SUM(MULTIPLY(Quantity, Price)); 'Road-650, Red, 60' is name of product; | SELECT SUM(T2.Quantity * T3.Price) FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T1.FirstName = 'Abraham' AND T1.MiddleInitial = 'e' AND T1.LastName = 'Bennet' AND T3.Name = 'Road-650 Red, 60' | CREATE TABLE Customers
(
CustomerID INTEGER not null
primary key,
FirstName TEXT not null,
MiddleInitial TEXT null,
LastName TEXT not null
);
CREATE TABLE Employees
(
EmployeeID INTEGER not null
primary key,
FirstName TEXT not null,
MiddleIn... |
food_inspection_2 | Among the establishments that paid a 500 fine, what is the percentage of restaurants? | a 500 fine refers to fine = 500; restaurant refers to facility_type = 'Restaurant'; percentage = divide(count(license_no where facility_type = 'Restaurant'), count(license_no)) * 100% where fine = 500 | SELECT CAST(COUNT(CASE WHEN T1.facility_type = 'Restaurant' THEN T1.license_no END) AS REAL) * 100 / COUNT(T1.facility_type) FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no INNER JOIN violation AS T3 ON T2.inspection_id = T3.inspection_id WHERE T3.fine = 500 | CREATE TABLE employee
(
employee_id INTEGER
primary key,
first_name TEXT,
last_name TEXT,
address TEXT,
city TEXT,
state TEXT,
zip INTEGER,
phone TEXT,
title TEXT,
salary INTEGER,
supervisor INTEGER,
foreign key (s... |
works_cycles | Please list all the vendors' usual selling prices of the product Hex Nut 5. | vendor's selling price refers to StandardPrice | SELECT T1.StandardPrice FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'Hex Nut 5' GROUP BY T1.StandardPrice ORDER BY COUNT(T1.StandardPrice) DESC LIMIT 1 | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE CountryRegion
(
CountryRegionCode TEXT not null
primary key,
Name TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE Culture
... |
movies_4 | What was the job of Dariusz Wolski in the movie "Pirates of the Caribbean: At World's End"? | movie "Pirates of the Caribbean: At World's End" refers to title = 'Pirates of the Caribbean: At World''s End' | SELECT T2.job FROM movie AS T1 INNER JOIN movie_crew AS T2 ON T1.movie_id = T2.movie_id INNER JOIN person AS T3 ON T2.person_id = T3.person_id WHERE T1.title LIKE 'Pirates of the Caribbean: At World%s End' AND T3.person_name = 'Dariusz Wolski' | CREATE TABLE country
(
country_id INTEGER not null
primary key,
country_iso_code TEXT default NULL,
country_name TEXT default NULL
);
CREATE TABLE department
(
department_id INTEGER not null
primary key,
department_name TEXT default NULL
);
CREATE TABLE gender
(
... |
image_and_language | How many images have over 20 object samples? | over 20 object samples refers to COUNT(OBJ_SAMPLE_ID) > 20 | SELECT COUNT(T1.IMG_ID) FROM ( SELECT IMG_ID FROM IMG_OBJ GROUP BY IMG_ID HAVING COUNT(OBJ_SAMPLE_ID) > 20 ) T1 | CREATE TABLE ATT_CLASSES
(
ATT_CLASS_ID INTEGER default 0 not null
primary key,
ATT_CLASS TEXT not null
);
CREATE TABLE OBJ_CLASSES
(
OBJ_CLASS_ID INTEGER default 0 not null
primary key,
OBJ_CLASS TEXT not null
);
CREATE TABLE IMG_OBJ
(
IMG_ID INTEGER default 0... |
mondial_geo | Which mountain does the river source Blue Nile located? State the height of the mountain. | SELECT T1.Name, T1.Height FROM mountain AS T1 INNER JOIN geo_mountain AS T2 ON T1.Name = T2.Mountain INNER JOIN province AS T3 ON T3.Name = T2.Province INNER JOIN geo_source AS T4 ON T4.Province = T3.Name WHERE T4.River = 'Blue Nile' | CREATE TABLE IF NOT EXISTS "borders"
(
Country1 TEXT default '' not null
constraint borders_ibfk_1
references country,
Country2 TEXT default '' not null
constraint borders_ibfk_2
references country,
Length REAL,
primary key (Country1, Country2)
);
CREATE TABLE I... | |
computer_student | Please list the IDs of all the faculty employees who teaches a basic or medium undergraduate course. | faculty employees refers to hasPosition = 'Faculty_eme'; basic or medium undergraduate course refers to courseLevel = 'Level_300' | SELECT T2.p_id FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id INNER JOIN person AS T3 ON T3.p_id = T2.p_id WHERE T1.courseLevel = 'Level_300' AND T3.hasPosition = 'Faculty_eme' | CREATE TABLE course
(
course_id INTEGER
constraint course_pk
primary key,
courseLevel TEXT
);
CREATE TABLE person
(
p_id INTEGER
constraint person_pk
primary key,
professor INTEGER,
student INTEGER,
hasPosition TEXT,
inPhase ... |
legislator | Calculate the percentage of legislators who are Senator and were born in 1964. | are senator refers to class IS NOT NULL; born in 1964 refers to birthday_bio = 1964; calculation = MULTIPLY(DIVIDE(COUNT(class IS NOT NULL THEN bioguide_id), COUNT(bioguide_id)), 1.0) | SELECT CAST(SUM(CASE WHEN T2.class IS NOT NULL THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM current AS T1 INNER JOIN `current-terms` AS T2 ON T1.bioguide_id = T2.bioguide WHERE T1.birthday_bio LIKE '%1964%' | CREATE TABLE current
(
ballotpedia_id TEXT,
bioguide_id TEXT,
birthday_bio DATE,
cspan_id REAL,
fec_id TEXT,
first_name TEXT,
gender_bio TEXT,
google_entity_id_id TEXT,
govtrack_id INTEGER,
house_history_id ... |
university | What is the university ID with the most students in 2011? | most students refers to MAX(num_students), in 2011 refers to year = 2011 | SELECT university_id FROM university_year WHERE year = 2011 ORDER BY num_students DESC LIMIT 1 | CREATE TABLE country
(
id INTEGER not null
primary key,
country_name TEXT default NULL
);
CREATE TABLE ranking_system
(
id INTEGER not null
primary key,
system_name TEXT default NULL
);
CREATE TABLE ranking_criteria
(
id INTEGER not null
... |
world_development_indicators | Mention the series code of countries using Hong Kong dollar as their currency unit. | SELECT T2.SeriesCode FROM Country AS T1 INNER JOIN CountryNotes AS T2 ON T1.CountryCode = T2.Countrycode WHERE T1.CurrencyUnit = 'Hong Kong dollar' | CREATE TABLE IF NOT EXISTS "Country"
(
CountryCode TEXT not null
primary key,
ShortName TEXT,
TableName TEXT,
LongName TEXT,
Alpha2Code ... | |
college_completion | Calculate the percentage of Black students in all private for profit institutions. | Black students refers to race = 'B'; private for profit refers to control = 'Private for-profit'; percentage = MULTIPLY(DIVIDE(SUM(race = 'B'), SUM(grad_cohort)), 100.0); | SELECT CAST(SUM(CASE WHEN T2.race = 'B' THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(T2.grad_cohort) FROM institution_details AS T1 INNER JOIN institution_grads AS T2 ON T1.unitid = T2.unitid WHERE T2.race = 'B' AND T1.control = 'Private for-profit' | CREATE TABLE institution_details
(
unitid INTEGER
constraint institution_details_pk
primary key,
chronname TEXT,
city TEXT,
state TEXT,
level ... |
books | List all the titles of the Spanish books published by Alfaguara. | "Spanish" is the language_name; 'Alfaguara' is the publisher_name | SELECT T2.title FROM book_language AS T1 INNER JOIN book AS T2 ON T2.language_id = T1.language_id INNER JOIN publisher AS T3 ON T3.publisher_id = T2.publisher_id WHERE T1.language_name = 'Spanish' AND T3.publisher_name = 'Alfaguara' GROUP BY T2.title | CREATE TABLE address_status
(
status_id INTEGER
primary key,
address_status TEXT
);
CREATE TABLE author
(
author_id INTEGER
primary key,
author_name TEXT
);
CREATE TABLE book_language
(
language_id INTEGER
primary key,
language_code TEXT,
language... |
address | How many counties are there in Virginia State? | "Virginia" is the state | SELECT COUNT(T2.county) FROM state AS T1 INNER JOIN country AS T2 ON T1.abbreviation = T2.state WHERE T1.name = 'Virginia' | CREATE TABLE CBSA
(
CBSA INTEGER
primary key,
CBSA_name TEXT,
CBSA_type TEXT
);
CREATE TABLE state
(
abbreviation TEXT
primary key,
name TEXT
);
CREATE TABLE congress
(
cognress_rep_id TEXT
primary key,
first_name TEXT,
last_name ... |
simpson_episodes | Calculate the percentage of the winners who are higher than 1.75 meters. | winners refers to result = 'Winner'; higher than 1.75 meters refers to height_meters > 1.75; percentage = divide(sum(result = 'Winner' and height_meters > 1.75), count(result = 'Winner' )) * 100%
| SELECT CAST(SUM(CASE WHEN T1.height_meters > 1.75 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM Person AS T1 INNER JOIN Award AS T2 ON T1.name = T2.person WHERE T2.result = 'Winner'; | CREATE TABLE IF NOT EXISTS "Episode"
(
episode_id TEXT
constraint Episode_pk
primary key,
season INTEGER,
episode INTEGER,
number_in_series INTEGER,
title TEXT,
summary TEXT,
air_date TEXT,
episode_image TEXT,
... |
car_retails | How many employees who are living in Australia and have the credit limit under 200000? State their email address and countries where they are working. | Australia is a country; creditLimit < 20000; | SELECT T2.email, T3.country FROM customers AS T1 INNER JOIN employees AS T2 ON T1.salesRepEmployeeNumber = T2.employeeNumber INNER JOIN offices AS T3 ON T2.officeCode = T3.officeCode WHERE T3.country = 'Australia' AND T1.creditLimit < 200000 AND T2.jobTitle = 'Sales Rep' | CREATE TABLE offices
(
officeCode TEXT not null
primary key,
city TEXT not null,
phone TEXT not null,
addressLine1 TEXT not null,
addressLine2 TEXT,
state TEXT,
country TEXT not null,
postalCode TEXT not null,
territory TEXT not null
);
CREATE... |
sales_in_weather | How many units of item no.5 were sold in store no.3 on the day the temperature range was the biggest? | item no. 5 refers to item_nbr = 5; store no.3 refers to store_nbr = 3; when the temperature range was the biggest refers to Max(Subtract(tmax, tmin)) | SELECT t2.units FROM relation AS T1 INNER JOIN sales_in_weather AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T1.station_nbr = T3.station_nbr WHERE T2.store_nbr = 3 AND T2.item_nbr = 5 ORDER BY t3.tmax - t3.tmin DESC LIMIT 1 | CREATE TABLE sales_in_weather
(
date DATE,
store_nbr INTEGER,
item_nbr INTEGER,
units INTEGER,
primary key (store_nbr, date, item_nbr)
);
CREATE TABLE weather
(
station_nbr INTEGER,
date DATE,
tmax INTEGER,
tmin INTEGER,
tavg INTEGER,
dep... |
talkingdata | Among all the users who use a vivo device, what is the percentage of the users in the M23-26 user group? | vivo device refers to phone_brand = 'vivo'; percentage = MULTIPLY(DIVIDE(COUNT(phone_brand = 'vivo WHERE group = 'M23-26), COUNT(phone_brand = 'vivo)), 100); M23-26 user group refers to group = 'M23-26'; | SELECT SUM(IIF(T1.`group` = 'M23-26', 1.0, 0)) / COUNT(T1.device_id) AS per FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.phone_brand = 'vivo' | CREATE TABLE `app_all`
(
`app_id` INTEGER NOT NULL,
PRIMARY KEY (`app_id`)
);
CREATE TABLE `app_events` (
`event_id` INTEGER NOT NULL,
`app_id` INTEGER NOT NULL,
`is_installed` INTEGER NOT NULL,
`is_active` INTEGER NOT NULL,
PRIMARY KEY (`event_id`,`app_id`),
FOREIGN KEY (`event_id`) REFERENCES `eve... |
university | What is the student staff ratio at the university with the greatest student staff ratio of all time? | greatest student staff ratio of all time refers to max(student_staff_ratio) | SELECT MAX(student_staff_ratio) FROM university_year ORDER BY student_staff_ratio DESC LIMIT 1 | CREATE TABLE country
(
id INTEGER not null
primary key,
country_name TEXT default NULL
);
CREATE TABLE ranking_system
(
id INTEGER not null
primary key,
system_name TEXT default NULL
);
CREATE TABLE ranking_criteria
(
id INTEGER not null
... |
public_review_platform | Indicate the opening hours of businesses are with category in fashion. | opening hours refers to opening_time; category refers to category_name; | SELECT T4.opening_time FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business AS T3 ON T2.business_id = T3.business_id INNER JOIN Business_Hours AS T4 ON T3.business_id = T4.business_id WHERE T1.category_name LIKE 'Fashion' | CREATE TABLE Attributes
(
attribute_id INTEGER
constraint Attributes_pk
primary key,
attribute_name TEXT
);
CREATE TABLE Categories
(
category_id INTEGER
constraint Categories_pk
primary key,
category_name TEXT
);
CREATE TABLE Compliments
(
compliment_id ... |
shakespeare | How many acts are there in Sonnets? | Sonnets refers to Title = 'Sonnets' | SELECT SUM(DISTINCT T2.Act) FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id WHERE T1.Title = 'Sonnets' | CREATE TABLE IF NOT EXISTS "chapters"
(
id INTEGER
primary key autoincrement,
Act INTEGER not null,
Scene INTEGER not null,
Description TEXT not null,
work_id INTEGER not null
references works
);
CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE IF NO... |
ice_hockey_draft | Among the Italian players, who has the shortest height? | Italian refers to nation = 'Italy'; players refers to PlayerName; shortest height refers to MIN(height_in_cm); | SELECT T2.PlayerName FROM height_info AS T1 INNER JOIN PlayerInfo AS T2 ON T1.height_id = T2.height WHERE T2.nation = 'Italy' ORDER BY T1.height_in_cm ASC LIMIT 1 | CREATE TABLE height_info
(
height_id INTEGER
primary key,
height_in_cm INTEGER,
height_in_inch TEXT
);
CREATE TABLE weight_info
(
weight_id INTEGER
primary key,
weight_in_kg INTEGER,
weight_in_lbs INTEGER
);
CREATE TABLE PlayerInfo
(
ELITEID INTE... |
works_cycles | Sum the total number of products rejected for having a trim length that is too long. | number of product rejected refers to ScrapedQty; trim length that is too long refers to scrap reason where Name = 'Trim length too long' | SELECT SUM(T2.ScrappedQty) FROM ScrapReason AS T1 INNER JOIN WorkOrder AS T2 ON T1.ScrapReasonID = T2.ScrapReasonID WHERE T1.Name = 'Trim length too long' | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE CountryRegion
(
CountryRegionCode TEXT not null
primary key,
Name TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE Culture
... |
food_inspection_2 | List down the address of employees who did inspection dated 11/5/2010. | dated 11/5/2010 refers to inspection_date = '2010-11-05' | SELECT DISTINCT T1.address FROM employee AS T1 INNER JOIN inspection AS T2 ON T1.employee_id = T2.employee_id WHERE T2.inspection_date = '2010-11-05' | CREATE TABLE employee
(
employee_id INTEGER
primary key,
first_name TEXT,
last_name TEXT,
address TEXT,
city TEXT,
state TEXT,
zip INTEGER,
phone TEXT,
title TEXT,
salary INTEGER,
supervisor INTEGER,
foreign key (s... |
video_games | Which year has the most number of PC games releases? | year refers to release_year; the most number of releases refers to max(count(game_id)) | SELECT T.release_year FROM ( SELECT T2.release_year, COUNT(DISTINCT T3.game_id) FROM platform AS T1 INNER JOIN game_platform AS T2 ON T1.id = T2.platform_id INNER JOIN game_publisher AS T3 ON T2.game_publisher_id = T3.id WHERE T1.platform_name = 'PC' GROUP BY T2.release_year ORDER BY COUNT(DISTINCT T3.game_id) DESC LIM... | CREATE TABLE genre
(
id INTEGER not null
primary key,
genre_name TEXT default NULL
);
CREATE TABLE game
(
id INTEGER not null
primary key,
genre_id INTEGER default NULL,
game_name TEXT default NULL,
foreign key (genre_id) references genre(id)
);
C... |
works_cycles | What is the difference between the actual manufacturing cost of product number 818 and the estimated manufacturing cost? | product number 818 refers to ProductID = 818; estimated manufacturing cost refers PlannedCost; actual manufacturing cost refers to ActualCost; difference = Substract(PlannedCost(ProductID(818))),(ActualCost(ProductID(818))); | SELECT PlannedCost - ActualCost FROM WorkOrderRouting WHERE ProductID = 818 | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE CountryRegion
(
CountryRegionCode TEXT not null
primary key,
Name TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE Culture
... |
computer_student | How many basic and medium undergraduate courses are there? | basic and medium undergraduate courses refers to courseLevel = 'Level_300' and courses refers to course.course_id | SELECT COUNT(*) FROM course WHERE courseLevel = 'Level_300' | CREATE TABLE course
(
course_id INTEGER
constraint course_pk
primary key,
courseLevel TEXT
);
CREATE TABLE person
(
p_id INTEGER
constraint person_pk
primary key,
professor INTEGER,
student INTEGER,
hasPosition TEXT,
inPhase ... |
menu | How many menus were created for steamship? | steamship refers to venue = 'STEAMSHIP'; | SELECT COUNT(*) FROM Menu WHERE venue = 'STEAMSHIP' | CREATE TABLE Dish
(
id INTEGER
primary key,
name TEXT,
description TEXT,
menus_appeared INTEGER,
times_appeared INTEGER,
first_appeared INTEGER,
last_appeared INTEGER,
lowest_price REAL,
highest_price REAL
);
CREATE TABLE Menu
(
id ... |
car_retails | For Which order was the most profitable, please list the customer name of the order and the profit of the order. | Most profitable order can be computed as MAX(MULTIPLY(quantityOrdered, SUBTRACT(priceEach, buyPrice)). | SELECT t3.customerName, (t1.priceEach - t4.buyPrice) * t1.quantityOrdered FROM orderdetails AS t1 INNER JOIN orders AS t2 ON t1.orderNumber = t2.orderNumber INNER JOIN customers AS t3 ON t2.customerNumber = t3.customerNumber INNER JOIN products AS t4 ON t1.productCode = t4.productCode GROUP BY t3.customerName, t1.price... | CREATE TABLE offices
(
officeCode TEXT not null
primary key,
city TEXT not null,
phone TEXT not null,
addressLine1 TEXT not null,
addressLine2 TEXT,
state TEXT,
country TEXT not null,
postalCode TEXT not null,
territory TEXT not null
);
CREATE... |
works_cycles | Which type of transaction was it for the "LL Road Handlebars" order happened in 2012/11/3? | Transactiontype = 'w' means 'WorkOrder'; transactiontype = 's' means 'SalesOrder'; transactiontype = 'P' means 'PurchaseOrder'; happened in refers to TransactionDate | SELECT T1.TransactionType FROM TransactionHistoryArchive AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'LL Road Handlebars' AND STRFTIME('%Y-%m-%d',T1.TransactionDate) = '2012-11-03' | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE CountryRegion
(
CountryRegionCode TEXT not null
primary key,
Name TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE Culture
... |
books | Name the streets in Dallas. | "Dallas" is the city; streets refers to street_name | SELECT street_name FROM address WHERE city = 'Dallas' | CREATE TABLE address_status
(
status_id INTEGER
primary key,
address_status TEXT
);
CREATE TABLE author
(
author_id INTEGER
primary key,
author_name TEXT
);
CREATE TABLE book_language
(
language_id INTEGER
primary key,
language_code TEXT,
language... |
retail_complains | Calculate the average age of clients from the Midwest region. | average age = AVG(age); | SELECT CAST(SUM(T1.age) AS REAL) / COUNT(T3.Region) AS average FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T2.state_abbrev = T3.StateCode WHERE T3.Region = 'Midwest' | CREATE TABLE state
(
StateCode TEXT
constraint state_pk
primary key,
State TEXT,
Region TEXT
);
CREATE TABLE callcenterlogs
(
"Date received" DATE,
"Complaint ID" TEXT,
"rand client" TEXT,
phonefinal TEXT,
"vru+line" TEXT,
call_id INTEG... |
movie_3 | List the actor's last name that starred the film with the description of "A Thoughtful Drama of a Composer And a Feminist who must Meet a Secret Agent in The Canadian Rockies". | SELECT T1.last_name FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T3.description = 'A Thoughtful Drama of a Composer And a Feminist who must Meet a Secret Agent in The Canadian Rockies' | CREATE TABLE film_text
(
film_id INTEGER not null
primary key,
title TEXT not null,
description TEXT null
);
CREATE TABLE IF NOT EXISTS "actor"
(
actor_id INTEGER
primary key autoincrement,
first_name TEXT not null,
last_nam... | |
books | Among the books ordered by Lucas Wyldbore, what is the percentage of those books over $13? | books over $13 refers to price > 13; percentage = Divide (Sum (order_id where price > 13), Count (order_id)) * 100 | SELECT CAST(SUM(CASE WHEN T1.price > 13 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM order_line AS T1 INNER JOIN cust_order AS T2 ON T2.order_id = T1.order_id INNER JOIN customer AS T3 ON T3.customer_id = T2.customer_id WHERE T3.first_name = 'Lucas' AND T3.last_name = 'Wyldbore' | CREATE TABLE address_status
(
status_id INTEGER
primary key,
address_status TEXT
);
CREATE TABLE author
(
author_id INTEGER
primary key,
author_name TEXT
);
CREATE TABLE book_language
(
language_id INTEGER
primary key,
language_code TEXT,
language... |
world | What is the surface area of the country where Sutton Coldfield city belongs? | SELECT T1.SurfaceArea FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode WHERE T2.Name = 'Sutton Coldfield' | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE `City` (
`ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`Name` TEXT NOT NULL DEFAULT '',
`CountryCode` TEXT NOT NULL DEFAULT '',
`District` TEXT NOT NULL DEFAULT '',
`Population` INTEGER NOT NULL DEFAULT 0,
FOREIGN KEY (`CountryCode`) REFERENCES `Countr... | |
olympics | Which region does the NOC code "COL" stand for? | region refers to region_name; NOC code "COL" refers to noc = 'COL'; | SELECT region_name FROM noc_region WHERE noc = 'COL' | CREATE TABLE city
(
id INTEGER not null
primary key,
city_name TEXT default NULL
);
CREATE TABLE games
(
id INTEGER not null
primary key,
games_year INTEGER default NULL,
games_name TEXT default NULL,
season TEXT default NULL
);
CREATE TABLE ga... |
olympics | What is the season of the game where a competitor who weighted 73 kg and 180 cm tall, participated? | competitor who weighted 73 kg and 180 cm tall refers to person_id where height = 180 and weight = 73; | SELECT DISTINCT T1.season FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.height = 180 AND T3.weight = 73 | CREATE TABLE city
(
id INTEGER not null
primary key,
city_name TEXT default NULL
);
CREATE TABLE games
(
id INTEGER not null
primary key,
games_year INTEGER default NULL,
games_name TEXT default NULL,
season TEXT default NULL
);
CREATE TABLE ga... |
disney | How many movies were released by Disney between 2010 and 2016? | Movies refer to movie_title; released between 2010 and 2016 refers to substr(release_date, length(release_date) - 1, length(release_date)) between '10' and '16'; | SELECT COUNT(movie_title) FROM characters WHERE SUBSTR(release_date, LENGTH(release_date) - 1, LENGTH(release_date)) BETWEEN '10' AND '16' | CREATE TABLE characters
(
movie_title TEXT
primary key,
release_date TEXT,
hero TEXT,
villian TEXT,
song TEXT,
foreign key (hero) references "voice-actors"(character)
);
CREATE TABLE director
(
name TEXT
primary key,
director TEXT,
fo... |
olympics | How many Men's 200 Metres Freestyle events did Ian James Thorpe compete in? | Men's 200 Metres Freestyle events refer to event_name = 'Swimming Men''s 200 metres Freestyle'; events compete in refers to event_id; | SELECT COUNT(T1.id) FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id INNER JOIN competitor_event AS T3 ON T2.id = T3.competitor_id INNER JOIN event AS T4 ON T3.event_id = T4.id WHERE T1.full_name = 'Ian James Thorpe' AND T4.event_name LIKE 'Swimming Men%s 200 metres Freestyle' | CREATE TABLE city
(
id INTEGER not null
primary key,
city_name TEXT default NULL
);
CREATE TABLE games
(
id INTEGER not null
primary key,
games_year INTEGER default NULL,
games_name TEXT default NULL,
season TEXT default NULL
);
CREATE TABLE ga... |
works_cycles | What is business number 1580's net profit? | business number 1580 refers to BusinessEntityID = 1580; Net profit = SUBTRACT(LastReceiptCost,StandardPrice) | SELECT LastReceiptCost - StandardPrice FROM ProductVendor WHERE BusinessEntityID = 1580 | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE CountryRegion
(
CountryRegionCode TEXT not null
primary key,
Name TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE Culture
... |
social_media | State the country where the most positive sentiment tweets were posted. | country with the most positive sentiment tweet refers to Country where Max(Count(Sentiment > 0)) | SELECT T.Country FROM ( SELECT T2.Country, SUM(T1.Sentiment) AS num FROM twitter AS T1 INNER JOIN location AS T2 ON T1.LocationID = T2.LocationID WHERE T1.Sentiment > 0 GROUP BY T2.Country ) T ORDER BY T.num DESC LIMIT 1 | CREATE TABLE location
(
LocationID INTEGER
constraint location_pk
primary key,
Country TEXT,
State TEXT,
StateCode TEXT,
City TEXT
);
CREATE TABLE user
(
UserID TEXT
constraint user_pk
primary key,
Gender TEXT
);
CREATE TABLE twitter
(
... |
movie_3 | What is the largest number of films rented per customer? | the largest number of films refers to MAX(rental_id) | SELECT COUNT(rental_id) FROM rental GROUP BY customer_id ORDER BY COUNT(rental_id) DESC LIMIT 1 | CREATE TABLE film_text
(
film_id INTEGER not null
primary key,
title TEXT not null,
description TEXT null
);
CREATE TABLE IF NOT EXISTS "actor"
(
actor_id INTEGER
primary key autoincrement,
first_name TEXT not null,
last_nam... |
retail_world | What is the average sales for each categories? | average sales = AVG(ProductSales) | SELECT AVG(ProductSales) FROM `Sales by Category` GROUP BY CategoryName | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE Categories
(
CategoryID INTEGER PRIMARY KEY AUTOINCREMENT,
CategoryName TEXT,
Description TEXT
);
CREATE TABLE Customers
(
CustomerID INTEGER PRIMARY KEY AUTOINCREMENT,
CustomerName TEXT,
ContactName TEXT,
Address TEXT,
City TEXT,
... |
donor | List by school id projects from schools located in the Union Pub School District I-9 that have a New York teaching fellow | located in the Union Pub School District I-9 refers to school_district = 'Union Pub School District I-9'; New York teaching fellow refers to teacher_ny_teaching_fellow = 't' | SELECT schoolid FROM projects WHERE school_district = 'Union Pub School District I-9' AND teacher_ny_teaching_fellow = 't' | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE IF NOT EXISTS "essays"
(
projectid TEXT,
teacher_acctid TEXT,
title TEXT,
short_description TEXT,
need_statement TEXT,
essay TEXT
);
CREATE TABLE IF NOT EXISTS "projects"
(
projectid ... |
public_review_platform | How many open businesses in the City of Phoenix have users left a long review? | open businesses refers to active = 'true'; long review refers to review_length = 'Long' | SELECT COUNT(DISTINCT T2.business_id) FROM Reviews AS T1 INNER JOIN Business AS T2 ON T1.business_id = T2.business_id WHERE T1.review_length = 'Long' AND T2.active = 'true' AND T2.city = 'Phoenix' | CREATE TABLE Attributes
(
attribute_id INTEGER
constraint Attributes_pk
primary key,
attribute_name TEXT
);
CREATE TABLE Categories
(
category_id INTEGER
constraint Categories_pk
primary key,
category_name TEXT
);
CREATE TABLE Compliments
(
compliment_id ... |
codebase_comments | Among all the solution of the 'zh-cn' methods, which path is most often used? | solution refers to SolutionId; zh-cn refers to Lang = 'zh-cn'; path that is most often used refers to MAX(COUNT(Path)); | SELECT T1.Path FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T2.Lang = 'zh-cn' GROUP BY T1.Path ORDER BY COUNT(T1.Path) DESC LIMIT 1 | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE IF NOT EXISTS "Method"
(
Id INTEGER not null
primary key autoincrement,
Name TEXT,
FullComment TEXT,
Summary TEXT,
ApiCalls TEXT,
CommentIsXml INTEGER,
SampledAt INTEGER,
SolutionId INTE... |
codebase_comments | Please give the url of the repository whose files are contained in solution ID 9? | SELECT T1.Url FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T2.Id = 9 | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE IF NOT EXISTS "Method"
(
Id INTEGER not null
primary key autoincrement,
Name TEXT,
FullComment TEXT,
Summary TEXT,
ApiCalls TEXT,
CommentIsXml INTEGER,
SampledAt INTEGER,
SolutionId INTE... | |
bike_share_1 | Name the station and city with the most borrowed bike. | the station with the most borrowed bikes refers to MAX(start_station); | SELECT T2.start_station_name, T1.city FROM station AS T1 INNER JOIN trip AS T2 ON T2.start_station_name = T1.name GROUP BY T2.start_station_name ORDER BY COUNT(T2.start_station_name) DESC LIMIT 1 | CREATE TABLE IF NOT EXISTS "station"
(
id INTEGER not null
primary key,
name TEXT,
lat REAL,
long REAL,
dock_count INTEGER,
city TEXT,
installation_date TEXT
);
CREATE TABLE IF NOT EXISTS "status"
(
statio... |
world_development_indicators | Mention the series code of countries using Australian dollar as their currency unit. Which country belongs to middle income group among them. | middle income group refers to IncomeGroup = 'Low middle income'; | SELECT T1.CountryCode, T2.SeriesCode FROM Country AS T1 INNER JOIN CountryNotes AS T2 ON T1.CountryCode = T2.Countrycode WHERE T1.CurrencyUnit = 'Australian dollar' AND T1.IncomeGroup = 'Lower middle income' | CREATE TABLE IF NOT EXISTS "Country"
(
CountryCode TEXT not null
primary key,
ShortName TEXT,
TableName TEXT,
LongName TEXT,
Alpha2Code ... |
food_inspection_2 | How many restaurants with the highest risk level still passed the inspection? | restaurant refers to facility_type = 'Restaurant'; the highest risk level refers to max(risk_level); pass the inspection refers to results = 'Pass' | SELECT COUNT(DISTINCT T1.license_no) FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no WHERE T1.risk_level = 3 AND T2.results = 'Pass' AND T1.facility_type = 'Restaurant' | CREATE TABLE employee
(
employee_id INTEGER
primary key,
first_name TEXT,
last_name TEXT,
address TEXT,
city TEXT,
state TEXT,
zip INTEGER,
phone TEXT,
title TEXT,
salary INTEGER,
supervisor INTEGER,
foreign key (s... |
works_cycles | Which Production Technician has the highest pay rate? | highest pay rate refers to MAX(Rate); | SELECT T1.BusinessEntityID FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.JobTitle LIKE 'Production Technician%' ORDER BY T2.Rate DESC LIMIT 1 | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE CountryRegion
(
CountryRegionCode TEXT not null
primary key,
Name TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE Culture
... |
mondial_geo | How many countries on the European Continent has an infant mortality rate per thousand of over 100? | SELECT COUNT(T1.Name) FROM country AS T1 INNER JOIN encompasses AS T2 ON T1.Code = T2.Country INNER JOIN continent AS T3 ON T3.Name = T2.Continent INNER JOIN population AS T4 ON T4.Country = T1.Code WHERE T3.Name = 'Europe' AND T4.Infant_Mortality < 100 | CREATE TABLE IF NOT EXISTS "borders"
(
Country1 TEXT default '' not null
constraint borders_ibfk_1
references country,
Country2 TEXT default '' not null
constraint borders_ibfk_2
references country,
Length REAL,
primary key (Country1, Country2)
);
CREATE TABLE I... | |
synthea | Calculate the average age of patients with prediabetes care plan. | SUBTRACT(SUM(deathdate), SUM(birthdate)), COUNT(patient) where REASONDESCRIPTION = 'Prediabetes' from careplans; | SELECT CAST(SUM(CASE WHEN T1.deathdate IS NULL THEN strftime('%Y', T2.STOP) - strftime('%Y', T1.birthdate) ELSE strftime('%Y', T1.deathdate) - strftime('%Y', T1.birthdate) END) AS REAL) / COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN careplans AS T2 ON T1.patient = T2.PATIENT WHERE T2.REASONDESCRIPTION = 'P... | CREATE TABLE all_prevalences
(
ITEM TEXT
primary key,
"POPULATION TYPE" TEXT,
OCCURRENCES INTEGER,
"POPULATION COUNT" INTEGER,
"PREVALENCE RATE" REAL,
"PREVALENCE PERCENTAGE" REAL
);
CREATE TABLE patients
(
patient TEXT
... |
computer_student | What is the sum of year 1 and year 2 students? | year 1 and year 2 students refers to yearsInProgram = 'Year_1' and yearsInProgram = 'Year_2' and student = 1 | SELECT COUNT(*) FROM person WHERE yearsInProgram = 'Year_1' OR yearsInProgram = 'Year_2' | CREATE TABLE course
(
course_id INTEGER
constraint course_pk
primary key,
courseLevel TEXT
);
CREATE TABLE person
(
p_id INTEGER
constraint person_pk
primary key,
professor INTEGER,
student INTEGER,
hasPosition TEXT,
inPhase ... |
movie_platform | What is the average score of the movie "The Fall of Berlin" in 2019? | The Fall of Berlin' is movie_title; in 2019 refers to rating_timestamp_utc = 2019; Average score refers to Avg(rating_score); | SELECT SUM(T1.rating_score) / COUNT(T1.rating_id) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T1.rating_timestamp_utc LIKE '2019%' AND T2.movie_title LIKE 'The Fall of Berlin' | CREATE TABLE IF NOT EXISTS "lists"
(
user_id INTEGER
references lists_users (user_id),
list_id INTEGER not null
primary key,
list_title TEXT,
list_movie_number INTEGER,
list_update_timestamp_utc TEXT,
list_creat... |
works_cycles | How many times is married non sales employees against single non-sales employees? | non-sales employee refers to PersonType = 'EM'; married refers to MaritalStatus = 'M'; single refers to MaritalStatus = 'S'; percentage = DIVIDE(SUM(MaritalStatus = 'M'), (SUM(MaritalStatus = 'S') as percentage; | SELECT CAST(SUM(CASE WHEN T1.MaritalStatus = 'M' THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(CASE WHEN T1.MaritalStatus = 'S' THEN 1 ELSE 0 END) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.PersonType = 'EM' | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE CountryRegion
(
CountryRegionCode TEXT not null
primary key,
Name TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE Culture
... |
law_episode | What is the average rating for each episode in season 9? | average rating = divide(sum(rating), count(episode_id)) | SELECT SUM(rating) / COUNT(episode_id) FROM Episode WHERE season = 9 | CREATE TABLE Episode
(
episode_id TEXT
primary key,
series TEXT,
season INTEGER,
episode INTEGER,
number_in_series INTEGER,
title TEXT,
summary TEXT,
air_date DATE,
episode_image TEXT,
rating ... |
donor | To which city did donor “22cbc920c9b5fa08dfb331422f5926b5” donate? | donor “22cbc920c9b5fa08dfb331422f5926b5” refers to donor_acctid = '22cbc920c9b5fa08dfb331422f5926b5'; city refers to donor_city | SELECT DISTINCT donor_city FROM donations WHERE donor_acctid = '22cbc920c9b5fa08dfb331422f5926b5' | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE IF NOT EXISTS "essays"
(
projectid TEXT,
teacher_acctid TEXT,
title TEXT,
short_description TEXT,
need_statement TEXT,
essay TEXT
);
CREATE TABLE IF NOT EXISTS "projects"
(
projectid ... |
social_media | For the tweet which got a reach number of 547851, which country did it come from? | reach number of 547851 refers to Reach = 547851 | SELECT T2.Country FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE T1.Reach = 547851 | CREATE TABLE location
(
LocationID INTEGER
constraint location_pk
primary key,
Country TEXT,
State TEXT,
StateCode TEXT,
City TEXT
);
CREATE TABLE user
(
UserID TEXT
constraint user_pk
primary key,
Gender TEXT
);
CREATE TABLE twitter
(
... |
regional_sales | Sate the order number and calculate the net profit for each order under Joshua Bennett. | net profit can be computed as SUBTRACT(Unit Price, Unit Cost); Joshua Bennett is the name of Sales Team; | SELECT T1.OrderNumber , REPLACE(T1.`Unit Price`, ',', '') - REPLACE(T1.`Unit Cost`, ',', '') FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE T2.`Sales Team` = 'Joshua Bennett' | CREATE TABLE Customers
(
CustomerID INTEGER
constraint Customers_pk
primary key,
"Customer Names" TEXT
);
CREATE TABLE Products
(
ProductID INTEGER
constraint Products_pk
primary key,
"Product Name" TEXT
);
CREATE TABLE Regions
(
StateCode TEXT
... |
retail_world | Calculate the average price of products shipped to the UK. | average price = divide(sum(UnitPrice) , count(ProductID)); the UK refers to Country = 'UK' | SELECT AVG(UnitPrice) AS avg FROM Invoices WHERE Country = 'UK' | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE Categories
(
CategoryID INTEGER PRIMARY KEY AUTOINCREMENT,
CategoryName TEXT,
Description TEXT
);
CREATE TABLE Customers
(
CustomerID INTEGER PRIMARY KEY AUTOINCREMENT,
CustomerName TEXT,
ContactName TEXT,
Address TEXT,
City TEXT,
... |
coinmarketcap | For all transactions for WRAP in August 2016, list the time to achieve highest price and the time to achieve the lowest price. | in May 2013 refers to month(date) = 5 AND year(date) = 2013; time to achieve the highest price refers to time_high; time to achieve the lowest price refers to time_low; WRAP refers to name = 'WARP' | SELECT T2.time_high, T2.time_low, T2.date FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'WARP' AND STRFTIME('%Y-%m', T2.date) = '2016-08' | CREATE TABLE coins
(
id INTEGER not null
primary key,
name TEXT,
slug TEXT,
symbol TEXT,
status TEXT,
category TEXT,
description TEXT,
subreddit TEXT,
notice TEXT,
tags TEXT,
tag_names TEXT,
... |
mental_health_survey | How many questions in 2014's survey had more than 200 answers? | 2014 refer to SurveyID; COUNT(QuestionID) where COUNT(AnswerText) > 200 | SELECT COUNT(QuestionID) FROM Answer WHERE SurveyID LIKE 2014 GROUP BY QuestionID ORDER BY COUNT(QuestionID) > 200 LIMIT 1 | CREATE TABLE Question
(
questiontext TEXT,
questionid INTEGER
constraint Question_pk
primary key
);
CREATE TABLE Survey
(
SurveyID INTEGER
constraint Survey_pk
primary key,
Description TEXT
);
CREATE TABLE IF NOT EXISTS "Answer"
(
AnswerText TEXT,
Sur... |
movie | What is the percentage of the actors that showed up in the credit list of movie "Dawn of the Planet of the Apes" that were born after "1970/1/1"? | movie "Dawn of the Planet of the Apes" refers to Title = 'Dawn of the Planet of the Apes'; born after "1970/1/1" refers to Date of Birth > '1970/1/1'; percentage = divide(count(ActorID where Date of Birth > '1970/1/1'), count(ActorID))*100% | SELECT CAST(SUM(CASE WHEN T3.`Date of Birth` > '1970-01-01' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T3.`Date of Birth`) FROM movie AS T1 INNER JOIN characters AS T2 ON T1.MovieID = T2.MovieID INNER JOIN actor AS T3 ON T3.ActorID = T2.ActorID WHERE T1.Title = 'Dawn of the Planet of the Apes' | CREATE TABLE actor
(
ActorID INTEGER
constraint actor_pk
primary key,
Name TEXT,
"Date of Birth" DATE,
"Birth City" TEXT,
"Birth Country" TEXT,
"Height (Inches)" INTEGER,
Biography TEXT,
Gender TEXT,
Ethnicity ... |
video_games | What are the sales made by the games in Japan region? | sales = SUM(num_sales); Japan region refers to region_name = 'Japan'; | SELECT SUM(CASE WHEN T2.region_name = 'Japan' THEN T1.num_sales ELSE 0 END) AS nums FROM region_sales AS T1 INNER JOIN region AS T2 ON T1.region_id = T2.id | CREATE TABLE genre
(
id INTEGER not null
primary key,
genre_name TEXT default NULL
);
CREATE TABLE game
(
id INTEGER not null
primary key,
genre_id INTEGER default NULL,
game_name TEXT default NULL,
foreign key (genre_id) references genre(id)
);
C... |
regional_sales | List down the customer names and product names of the order made by "Anthony Torres" via distributor channel. | "Anthony Torres" is the name of Sales Team; distributor channel refers to Sales Channel = 'Distributor' | SELECT DISTINCT T1.`Customer Names`, T4.`Product Name` FROM Customers AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._CustomerID = T1.CustomerID INNER JOIN `Sales Team` AS T3 ON T3.SalesTeamID = T2._SalesTeamID INNER JOIN Products AS T4 ON T4.ProductID = T2._ProductID WHERE T3.`Sales Team` = 'Anthony Torres' AND T2.`Sales... | CREATE TABLE Customers
(
CustomerID INTEGER
constraint Customers_pk
primary key,
"Customer Names" TEXT
);
CREATE TABLE Products
(
ProductID INTEGER
constraint Products_pk
primary key,
"Product Name" TEXT
);
CREATE TABLE Regions
(
StateCode TEXT
... |
shakespeare | Please list all of the paragraphs that have the character name Aedile. | paragraphs refers to ParagraphNum; character name Aedile refers to CharName = 'Aedile' | SELECT T2.ParagraphNum FROM characters AS T1 INNER JOIN paragraphs AS T2 ON T1.id = T2.character_id WHERE T1.CharName = 'Aedile' | CREATE TABLE IF NOT EXISTS "chapters"
(
id INTEGER
primary key autoincrement,
Act INTEGER not null,
Scene INTEGER not null,
Description TEXT not null,
work_id INTEGER not null
references works
);
CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE IF NO... |
retails | What is the discounted price of line item number 1? | discounted price refers to multiply(l_extendedprice, subtract(1, l_discount)); line item number 1 refers to l_linenumber = 1 | SELECT l_extendedprice * (1 - l_discount) FROM lineitem WHERE l_linenumber = 1 | CREATE TABLE `customer` (
`c_custkey` INTEGER NOT NULL,
`c_mktsegment` TEXT DEFAULT NULL,
`c_nationkey` INTEGER DEFAULT NULL,
`c_name` TEXT DEFAULT NULL,
`c_address` TEXT DEFAULT NULL,
`c_phone` TEXT DEFAULT NULL,
`c_acctbal` REAL DEFAULT NULL,
`c_comment` TEXT DEFAULT NULL,
PRIMARY KEY (`c_custkey`),... |
retail_world | How many suppliers in Australia whose products were discontinued? | in Australia refers to Country = 'Australia'; discontinued refers to Discontinued = 1 | SELECT COUNT(T1.Discontinued) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.Discontinued = 1 AND T2.Country = 'Australia' | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE Categories
(
CategoryID INTEGER PRIMARY KEY AUTOINCREMENT,
CategoryName TEXT,
Description TEXT
);
CREATE TABLE Customers
(
CustomerID INTEGER PRIMARY KEY AUTOINCREMENT,
CustomerName TEXT,
ContactName TEXT,
Address TEXT,
City TEXT,
... |
language_corpus | What are the total occurence of words that paired with "nombre"? | total occurrence refers to sum(occurrences); paired with "nombre" refers to w1st.word = "nombre" or w2nd.word = "nombre" | SELECT SUM(T2.occurrences) FROM words AS T1 INNER JOIN biwords AS T2 ON T1.wid = T2.w1st OR T1.wid = T2.w2nd WHERE T2.w1st IN (( SELECT wid FROM words WHERE word = 'nombre' ) OR T2.w2nd IN ( SELECT wid FROM words WHERE word = 'nombre' )) | CREATE TABLE langs(lid INTEGER PRIMARY KEY AUTOINCREMENT,
lang TEXT UNIQUE,
locale TEXT UNIQUE,
pages INTEGER DEFAULT 0, -- total pages in this language
words INTEGER DEFAULT 0);
CREATE TABLE sqlite_s... |
olympics | Where is competitor Estelle Nze Minko from? | Where competitor is from refers to region_name; | SELECT T1.region_name FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.full_name = 'Estelle Nze Minko' | CREATE TABLE city
(
id INTEGER not null
primary key,
city_name TEXT default NULL
);
CREATE TABLE games
(
id INTEGER not null
primary key,
games_year INTEGER default NULL,
games_name TEXT default NULL,
season TEXT default NULL
);
CREATE TABLE ga... |
retails | How many suppliers from Egypt have a debit balance? | suppliers refer to s_suppkey; Egypt is the name of the nation which refers to n_name = 'EGYPT'; the balance is in debt if s_acctbal < 0; | SELECT COUNT(T1.s_suppkey) FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey WHERE T1.s_acctbal < 0 AND T2.n_name = 'EGYPT' | CREATE TABLE `customer` (
`c_custkey` INTEGER NOT NULL,
`c_mktsegment` TEXT DEFAULT NULL,
`c_nationkey` INTEGER DEFAULT NULL,
`c_name` TEXT DEFAULT NULL,
`c_address` TEXT DEFAULT NULL,
`c_phone` TEXT DEFAULT NULL,
`c_acctbal` REAL DEFAULT NULL,
`c_comment` TEXT DEFAULT NULL,
PRIMARY KEY (`c_custkey`),... |
legislator | Among legislators who have an Instagram account, list down their full names and nicknames who have a Thomas ID of less than 1000. | have an Instagram account refers to instagram is not null; full names refers to official_full_name; nicknames refers to nickname_name; Thomas ID of less than 1000 refers to thomas_id < 1000; | SELECT T1.official_full_name, T1.nickname_name FROM current AS T1 INNER JOIN `social-media` AS T2 ON T2.bioguide = T1.bioguide_id WHERE T2.instagram IS NOT NULL AND T1.thomas_id < 1000 | CREATE TABLE current
(
ballotpedia_id TEXT,
bioguide_id TEXT,
birthday_bio DATE,
cspan_id REAL,
fec_id TEXT,
first_name TEXT,
gender_bio TEXT,
google_entity_id_id TEXT,
govtrack_id INTEGER,
house_history_id ... |
professional_basketball | List the full name and age of the player when he won the "Finals MVP" in 2003. | full name refers to firstName, middleName, lastName; age = subtract(2003, year(birthDate)); won the "Finals MVP" refers to award = 'Finals MVP'; in 2003 refers to year = 2003 | SELECT T1.firstName, T1.middleName, T1.lastName , 2003 - strftime('%Y', T1.birthDate) FROM awards_players AS T2 JOIN players AS T1 ON T2.playerID = T1.playerID WHERE T2.award = 'Finals MVP' AND T2.year = 2003 | CREATE TABLE awards_players
(
playerID TEXT not null,
award TEXT not null,
year INTEGER not null,
lgID TEXT null,
note TEXT null,
pos TEXT null,
primary key (playerID, year, award),
foreign key (playerID) references players (playerID)
on update ca... |
soccer_2016 | How many players were born in the 80s and have bowling skill of 2? | born in the 80s refers to DOB like '198%'; have bowling skill of 2 refers to Bowling_skill = 2; | SELECT COUNT(Player_Name) FROM Player WHERE DOB LIKE '198%' AND Bowling_skill = 2 | CREATE TABLE Batting_Style
(
Batting_Id INTEGER
primary key,
Batting_hand TEXT
);
CREATE TABLE Bowling_Style
(
Bowling_Id INTEGER
primary key,
Bowling_skill TEXT
);
CREATE TABLE City
(
City_Id INTEGER
primary key,
City_Name TEXT,
Country_id INTEGE... |
cookbook | List all the ingredients for Strawberry Sorbet. | Strawberry Sorbet refers to title | SELECT T3.name FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id WHERE T1.title = 'Strawberry Sorbet' | CREATE TABLE Ingredient
(
ingredient_id INTEGER
primary key,
category TEXT,
name TEXT,
plural TEXT
);
CREATE TABLE Recipe
(
recipe_id INTEGER
primary key,
title TEXT,
subtitle TEXT,
servings INTEGER,
yield_unit TEXT,
prep_min... |
cs_semester | Among students that gave satisfaction of value 4 for the course named "Statistical Learning", how many of them have a gpa of 3.8? | satisfaction refers to sat;
sat = 4; gpa = 3.8 | SELECT COUNT(T1.student_id) FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T3.name = 'Statistical learning' AND T2.sat = 4 AND T1.gpa = 3.8 | CREATE TABLE IF NOT EXISTS "course"
(
course_id INTEGER
constraint course_pk
primary key,
name TEXT,
credit INTEGER,
diff INTEGER
);
CREATE TABLE prof
(
prof_id INTEGER
constraint prof_pk
primary key,
gender TEXT,
first_na... |
works_cycles | Average cost of purchase orders made during the first six months of 2012. | purchase orders refers to TransactionType = 'P'; first six months of 2012 refers to TransactionDate bewteen '2012-01-01'and '2012-06-30'; average = DIVIDE(ActualCost where TransactionType = 'P', count(TransactionID))
| SELECT CAST(SUM(ActualCost) AS REAL) / COUNT(TransactionID) FROM TransactionHistoryArchive WHERE TransactionType = 'P' AND TransactionDate >= '2012-01-01' AND TransactionDate < '2012-07-01' | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE CountryRegion
(
CountryRegionCode TEXT not null
primary key,
Name TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE Culture
... |
university | Among universities that score below 80 in 2015, what is the percentage of international students? | score below 80 refers to score < 80; in 2015 refers to year 2015; percentage of international students refers to DIVIDE(SUM(DIVIDE(MULTIPLY(num_students, pct_international_students), 100)), SUM(num_students)) | SELECT SUM(CAST(T1.num_students * T1.pct_international_students AS REAL) / 100) / COUNT(*) * 100 FROM university_year AS T1 INNER JOIN university_ranking_year AS T2 ON T1.university_id = T2.university_id WHERE T2.score < 80 AND T1.year = 2015 | CREATE TABLE country
(
id INTEGER not null
primary key,
country_name TEXT default NULL
);
CREATE TABLE ranking_system
(
id INTEGER not null
primary key,
system_name TEXT default NULL
);
CREATE TABLE ranking_criteria
(
id INTEGER not null
... |
movie_3 | Give the total amount of rent for the movie Clockwork Paradice. | 'Clockwork Paradice' is a title of a film | SELECT SUM(T1.amount) FROM payment AS T1 INNER JOIN rental AS T2 ON T1.rental_id = T2.rental_id INNER JOIN inventory AS T3 ON T2.inventory_id = T3.inventory_id INNER JOIN film AS T4 ON T3.film_id = T4.film_id WHERE T4.title = 'CLOCKWORK PARADICE' | CREATE TABLE film_text
(
film_id INTEGER not null
primary key,
title TEXT not null,
description TEXT null
);
CREATE TABLE IF NOT EXISTS "actor"
(
actor_id INTEGER
primary key autoincrement,
first_name TEXT not null,
last_nam... |
public_review_platform | What is the longest business time on Mondays for a Yelp_Business under the category "Shopping"? | longest business time refers to max(subtract(closing_time, opening_time)); on Mondays refers to day_of_week = 'Monday'; category "Shopping" refers to category_name = 'Shopping' | SELECT T1.closing_time + 12 - T1.opening_time AS "hour" FROM Business_Hours AS T1 INNER JOIN Days AS T2 ON T1.day_id = T2.day_id INNER JOIN Business AS T3 ON T1.business_id = T3.business_id INNER JOIN Business_Categories AS T4 ON T3.business_id = T4.business_id INNER JOIN Categories AS T5 ON T4.category_id = T5.categor... | CREATE TABLE Attributes
(
attribute_id INTEGER
constraint Attributes_pk
primary key,
attribute_name TEXT
);
CREATE TABLE Categories
(
category_id INTEGER
constraint Categories_pk
primary key,
category_name TEXT
);
CREATE TABLE Compliments
(
compliment_id ... |
legislator | Among male legislators, state number of the legislators who are not the senator. | male refers to gender_bio = M; not the senator refers to class IS NULL OR class = '' | SELECT COUNT(T3.state) FROM ( SELECT T2.state FROM current AS T1 INNER JOIN `current-terms` AS T2 ON T1.bioguide_id = T2.bioguide WHERE T1.gender_bio = 'M' AND (T2.class IS NULL OR T2.class = '') GROUP BY T2.state ) T3 | CREATE TABLE current
(
ballotpedia_id TEXT,
bioguide_id TEXT,
birthday_bio DATE,
cspan_id REAL,
fec_id TEXT,
first_name TEXT,
gender_bio TEXT,
google_entity_id_id TEXT,
govtrack_id INTEGER,
house_history_id ... |
disney | Please list the villains of all the movies directed by Wolfgang Reitherman. | Wolfgang Reitherman refers to director = 'Wolfgang Reitherman'; | SELECT T2.villian FROM director AS T1 INNER JOIN characters AS T2 ON T1.name = T2.movie_title WHERE T1.director = 'Wolfgang Reitherman' AND T2.villian IS NOT NULL | CREATE TABLE characters
(
movie_title TEXT
primary key,
release_date TEXT,
hero TEXT,
villian TEXT,
song TEXT,
foreign key (hero) references "voice-actors"(character)
);
CREATE TABLE director
(
name TEXT
primary key,
director TEXT,
fo... |
world_development_indicators | List the series code of country with country notes description as "Data sources : Eurostat" and state the Wb2Code of these countries. | SELECT T2.seriescode, T1.Wb2Code FROM Country AS T1 INNER JOIN CountryNotes AS T2 ON T1.CountryCode = T2.Countrycode WHERE T2.Description = 'Data sources : Eurostat' | CREATE TABLE IF NOT EXISTS "Country"
(
CountryCode TEXT not null
primary key,
ShortName TEXT,
TableName TEXT,
LongName TEXT,
Alpha2Code ... | |
simpson_episodes | How many crew have their own nickname? List their full name along with the nickname. | crew refers to Person; full name refers to name; have nickname refers to nickname IS NOT NULL | SELECT COUNT(name) FROM Person WHERE nickname IS NOT NULL; | CREATE TABLE IF NOT EXISTS "Episode"
(
episode_id TEXT
constraint Episode_pk
primary key,
season INTEGER,
episode INTEGER,
number_in_series INTEGER,
title TEXT,
summary TEXT,
air_date TEXT,
episode_image TEXT,
... |
donor | What is the average donation amount to a project created by a teacher working in a school in Brooklyn? | school in Brooklyn refers to school_city = 'Brooklyn'; Average = AVG(donation_total); | SELECT SUM(T2.donation_total) / COUNT(donationid) FROM projects AS T1 INNER JOIN donations AS T2 ON T1.projectid = T2.projectid WHERE T1.school_city = 'Brooklyn' | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE IF NOT EXISTS "essays"
(
projectid TEXT,
teacher_acctid TEXT,
title TEXT,
short_description TEXT,
need_statement TEXT,
essay TEXT
);
CREATE TABLE IF NOT EXISTS "projects"
(
projectid ... |
shakespeare | How many acts can be found in the comedy "Two Gentlemen of Verona"? | comedy refers to GenreType = 'comedy'; "Two Gentlemen of Verona" refers to Title = 'Two Gentlemen of Verona' | SELECT COUNT(T1.ACT) FROM chapters AS T1 LEFT JOIN works AS T2 ON T1.work_id = T2.id WHERE T2.GenreType = 'Comedy' AND T2.Title = 'Two Gentlemen of Verona' | CREATE TABLE IF NOT EXISTS "chapters"
(
id INTEGER
primary key autoincrement,
Act INTEGER not null,
Scene INTEGER not null,
Description TEXT not null,
work_id INTEGER not null
references works
);
CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE IF NO... |
synthea | State the description of the reason why Angelo Buckridge needs the care plan. | description of the reason of the care plan refers to careplans.REASONDESCRIPTION; | SELECT DISTINCT T1.REASONDESCRIPTION FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.first = 'Angelo' AND T2.last = 'Buckridge' | CREATE TABLE all_prevalences
(
ITEM TEXT
primary key,
"POPULATION TYPE" TEXT,
OCCURRENCES INTEGER,
"POPULATION COUNT" INTEGER,
"PREVALENCE RATE" REAL,
"PREVALENCE PERCENTAGE" REAL
);
CREATE TABLE patients
(
patient TEXT
... |
retail_world | List the product ID of the top five products, by descending order, the number of quantities in stock. | by descending in number of quantity in stock refers to max(UnitsInStock) | SELECT ProductID FROM Products ORDER BY UnitsInStock DESC LIMIT 5 | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE Categories
(
CategoryID INTEGER PRIMARY KEY AUTOINCREMENT,
CategoryName TEXT,
Description TEXT
);
CREATE TABLE Customers
(
CustomerID INTEGER PRIMARY KEY AUTOINCREMENT,
CustomerName TEXT,
ContactName TEXT,
Address TEXT,
City TEXT,
... |
hockey | For all the referees, who became a hall of famer in the 1970s? What's his hofID? | 1970s refers to year between 1970 and 1979; referees stand for category; | SELECT name, hofID FROM HOF WHERE category = 'Builder' AND year BETWEEN 1970 AND 1979 | CREATE TABLE AwardsMisc
(
name TEXT not null
primary key,
ID TEXT,
award TEXT,
year INTEGER,
lgID TEXT,
note TEXT
);
CREATE TABLE HOF
(
year INTEGER,
hofID TEXT not null
primary key,
name TEXT,
category TEXT
);
CREATE TABLE Teams
(
year ... |
image_and_language | What is the predicate class of image ID 68? | predicate class of image ID 68 refers to PRED_CLASS where IMG_ID = 68; | SELECT T2.PRED_CLASS FROM IMG_REL AS T1 INNER JOIN PRED_CLASSES AS T2 ON T1.PRED_CLASS_ID = T2.PRED_CLASS_ID WHERE T1.IMG_ID = 68 | CREATE TABLE ATT_CLASSES
(
ATT_CLASS_ID INTEGER default 0 not null
primary key,
ATT_CLASS TEXT not null
);
CREATE TABLE OBJ_CLASSES
(
OBJ_CLASS_ID INTEGER default 0 not null
primary key,
OBJ_CLASS TEXT not null
);
CREATE TABLE IMG_OBJ
(
IMG_ID INTEGER default 0... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.