db_id
stringclasses
69 values
question
stringlengths
24
325
evidence
stringlengths
0
673
SQL
stringlengths
23
804
schema
stringclasses
69 values
movie_platform
Between 1/1/2010 to 12/31/2020, how many users, who were a trialist when they created the list, gave the movie "The Secret Life of Words" a rating score of 3?
Between 1/1/2010 to 12/31/2020 refers to rating_timestamp_utc between '2010-01-01%' and '2020-12-31%'; a trialist refers to user_trialist = 1; movie "The Secret Life of Words" refers to movie_title = 'The Secret Life of Words'; rating score of 3 refers to rating_score = 3
SELECT COUNT(T1.user_id) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.movie_title = 'The Secret Life of Words' AND T1.rating_score = 3 AND T1.user_trialist = 0 AND T1.rating_timestamp_utc BETWEEN '2010%' AND '2020%'
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...
law_episode
Which episode has the highest total number of viewer votes?
episode refers to title; the highest total number of viewer votes refers to max(sum(votes))
SELECT T1.title FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id GROUP BY T1.title ORDER BY SUM(T1.votes) DESC LIMIT 1
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 ...
regional_sales
Which regions have online sales channels that have the most discounts?
most discount refers to Max(Discount Applied)
SELECT T2.Region FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE T1.`Sales Channel` = 'Online' ORDER BY T1.`Discount Applied` DESC LIMIT 1
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 ...
talkingdata
What is the brand of the youngest user's device?
brand of the device refers to phone_brand; youngest user refers to MIN(age);
SELECT device_model FROM phone_brand_device_model2 WHERE device_id IN ( SELECT device_id FROM gender_age WHERE age = ( SELECT MIN(age) FROM gender_age ) )
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...
social_media
List down the text of tweets posted by unknown gender users.
unknown gender user refers to Gender = 'Unknown'
SELECT T1.text FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID WHERE T2.Gender = 'Unknown'
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 ( ...
movies_4
What is the ratio between male and female cast members of the movie 'Iron Man?' Count how many have unspecified genders.
male refers to gender = 'Male'; female refers to gender = 'Female'; movie 'Iron Man' refers to title = 'Iron Man'; ratio = divide(sum(gender = 'Female'), sum(gender = 'Male'))
SELECT CAST(COUNT(CASE WHEN T3.gender = 'Male' THEN 1 ELSE NULL END) AS REAL) / COUNT(CASE WHEN T3.gender = 'Female' THEN 1 ELSE NULL END) AS RATIO , COUNT(CASE WHEN T3.gender = 'Unspecified' THEN 1 ELSE NULL END) AS UNGENDERS FROM movie AS T1 INNER JOIN movie_cast AS T2 ON T1.movie_id = T2.movie_id INNER JOIN gender A...
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 ( ...
movie_platform
When was the first movie of the director who directed the highest number of movies released and what is the user id of the user who received the highest number of comments related to the critic made by the user rating the movie?
comments refer to critic_comments
SELECT MIN(movie_release_year) FROM movies WHERE director_name = ( SELECT T2.director_name FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.movie_release_year BETWEEN 1960 AND 1985 GROUP BY T2.director_name ORDER BY COUNT(T2.director_name) DESC LIMIT 1 )
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...
books
List all the authors who wrote fewer pages than the average.
author refers to author_name; who wrote fewer pages than the average refers to num_pages < AVG(num_pages)
SELECT T3.author_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T1.num_pages < ( SELECT AVG(num_pages) FROM book )
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...
soccer_2016
List down the match ID of matches that the "man of the match" award was given to BB McCullum.
SELECT T1.Match_Id FROM Match AS T1 INNER JOIN Player AS T2 ON T2.Player_Id = T1.Man_of_the_Match WHERE T2.Player_Name = 'BB McCullum'
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...
world_development_indicators
What is the percentage of increase of the indicator on Adolescent fertility rate from 1960 to 1961 in the country whose Alpha2Code is 1A?
the percentage of increase from 1960 to 1961 = divide(subtract(sum(value where Year = 1961), sum(Value where Year = 1960)), sum(Value where Year = 1960)) *100%; indicator on Adolescent fertility rate refers to IndicatorName = 'Adolescent fertility rate (births per 1,000 women ages 15-19)%'
SELECT (( SELECT T2.Value FROM Country AS T1 INNER JOIN Indicators AS T2 ON T1.CountryCode = T2.CountryCode WHERE T1.Alpha2Code = '1A' AND T2.IndicatorName = 'Adolescent fertility rate (births per 1,000 women ages 15-19)' AND T2.Year = 1961 ) - ( SELECT T2.Value FROM Country AS T1 INNER JOIN Indicators AS T2 ON T1.Coun...
CREATE TABLE IF NOT EXISTS "Country" ( CountryCode TEXT not null primary key, ShortName TEXT, TableName TEXT, LongName TEXT, Alpha2Code ...
student_loan
How many students enlisted in the navy?
navy refers to organ = 'navy';
SELECT COUNT(name) FROM enlist WHERE organ = 'navy'
CREATE TABLE bool ( "name" TEXT default '' not null primary key ); CREATE TABLE person ( "name" TEXT default '' not null primary key ); CREATE TABLE disabled ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update c...
food_inspection_2
How many employees are living in Hoffman Estates, IL?
in Hoffman Estates refers to city = 'Hoffman Estates'; IL refers to state = 'IL'
SELECT COUNT(employee_id) FROM employee WHERE state = 'IL' AND city = 'Hoffman Estates'
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...
movie_3
How many non-active clients have not returned the rented material?
non-active clients refers to active = 0; not returning a rented material refers to rental_date is null
SELECT COUNT(T2.customer_id) FROM rental AS T1 INNER JOIN customer AS T2 ON T1.customer_id = T2.customer_id WHERE T2.active = 0
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
Give the full name of the youngest employee.
full name = FirstName, LastName; youngest refers to latest BirthDate;
SELECT FirstName, LastName FROM Employees WHERE BirthDate = ( SELECT MAX(BirthDate) 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, ...
beer_factory
What did the customer say in his or her review of Bulldog root beer on 7/26/2013?
Bulldog refers to BrandName = 'Bulldog'; on 7/26/2013 refers to ReviewDate = '2013-07-26';
SELECT T2.Review FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T1.BrandName = 'Bulldog' AND T2.ReviewDate = '2013-07-26'
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
world_development_indicators
List out the long name of countries using series code as DT.DOD.DSTC.CD
SELECT T1.LongName FROM Country AS T1 INNER JOIN CountryNotes AS T2 ON T1.CountryCode = T2.Countrycode WHERE T2.SeriesCode = 'DT.DOD.DSTC.CD'
CREATE TABLE IF NOT EXISTS "Country" ( CountryCode TEXT not null primary key, ShortName TEXT, TableName TEXT, LongName TEXT, Alpha2Code ...
food_inspection_2
Provide the last name of the employee involved in the inspection ID 52256.
SELECT DISTINCT T1.last_name FROM employee AS T1 INNER JOIN inspection AS T2 ON T1.employee_id = T2.employee_id WHERE T2.inspection_id = 52256
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...
mental_health_survey
For the question “What US state or territory do you work in?”, how many people gave "Kansas" as the answer?
question refers to questiontext; AnswerText = 'Kansas'
SELECT COUNT(T1.UserID) FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T2.questiontext LIKE 'What US state or territory do you work in?' AND T1.AnswerText = 'Kansas'
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_3
Which film has the longest duration of film screening? Please give its title.
longest duration of film refers to Max(length)
SELECT title FROM film ORDER BY length 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...
public_review_platform
What is the percentage of user not becoming an elite user?
DIVIDE(SUBTRACT(COUNT(user_id), COUNT(Elite.user_id)), COUNT(user_id)) as percentage;
SELECT CAST((( SELECT COUNT(user_id) FROM Users ) - ( SELECT COUNT(DISTINCT user_id) FROM Elite )) AS REAL) * 100 / ( SELECT COUNT(user_id) FROM Users )
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 ...
bike_share_1
How many trips made by a subscriber started in August, 2013 from a station that can hold more than 20 bikes?
subscriber refers to subscription_type = 'Subscriber'; in August 2013 refers to start_date LIKE'8%' AND start_date LIKE'%2013%'; station that can hold more than 20 bikes refers to dock_count>20;
SELECT COUNT(T2.id) FROM station AS T1 INNER JOIN trip AS T2 ON T1.id = T2.start_station_id WHERE T2.subscription_type = 'Subscriber' AND T2.start_date LIKE '8/%/2013%' AND T1.dock_count > 20
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...
ice_hockey_draft
Who has played the most game plays in the 2000-2001 season of the International league?
played the most game plays refers to MAX(GP); 2000-2001 season refers to SEASON = '2000-2001'; International league refers to LEAGUE = 'International';
SELECT DISTINCT T2.PlayerName FROM SeasonStatus AS T1 INNER JOIN PlayerInfo AS T2 ON T1.ELITEID = T2.ELITEID WHERE T1.SEASON = '2000-2001' AND T1.LEAGUE = 'International' ORDER BY T1.GP DESC 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...
talkingdata
Which behavior category does user number 5902120154267990000 belong to?
behavior category refers to category; number refers to app_id; app_id = 5902120154267990000;
SELECT T1.category FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id WHERE T2.app_id = 5902120154267990000
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...
app_store
How much is the size of Browser 4G and how many users have a pretty positive favorability on it?
Browser 4G is the App; pretty positive favorability refers to Sentiment_Polarity score = 0.5
SELECT T1.Size, COUNT(T1.App) FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.App = 'Browser 4G' AND T2.Sentiment_Polarity >= 0.5
CREATE TABLE IF NOT EXISTS "playstore" ( App TEXT, Category TEXT, Rating REAL, Reviews INTEGER, Size TEXT, Installs TEXT, Type TEXT, Price TEXT, "Content Rating" TEXT, Genres TEXT ); CREA...
beer_factory
What is the container type, brand name and star rating for root beer ID 10054?
FALSE;
SELECT T4.ContainerType, T3.BrandName, T1.StarRating FROM rootbeerreview AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID INNER JOIN rootbeer AS T4 ON T2.RootBeerID = T4.RootBeerID WHERE T2.RootBeerID = 100054
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
student_loan
Does student348 have a due payment?
payment due refers to bool = 'pos' means the student has payment due , bool = 'neg' means the student does not have payment due;
SELECT bool FROM no_payment_due WHERE name = 'student348'
CREATE TABLE bool ( "name" TEXT default '' not null primary key ); CREATE TABLE person ( "name" TEXT default '' not null primary key ); CREATE TABLE disabled ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update c...
cs_semester
Among professors with the highest popularity, how many of their students have research capability of 5?
highest popularity refers to MAX(popularity); research capability refers to capability; capability = 5;
SELECT COUNT(T1.student_id) FROM RA AS T1 INNER JOIN prof AS T2 ON T1.prof_id = T2.prof_id WHERE T1.capability = 5 ORDER BY T2.popularity DESC LIMIT 1
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...
retails
How many items shipped by REG AIR were ordered on March 22, 1995?
items shipped by REG AIR refer to l_linenumber where l_shipmode = 'REG AIR'; ordered on March 22, 1995 refers to o_orderdate = '1995-03-22';
SELECT COUNT(T1.o_orderkey) FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey WHERE T2.l_shipmode = 'REG AIR' AND T1.o_orderdate = '1995-03-22'
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`),...
beer_factory
How many bottles of beer have been bought by Jim Breech?
bottles refers to ContainerType = 'Bottle';
SELECT COUNT(T3.ContainerType) FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T2.CustomerID = T1.CustomerID INNER JOIN rootbeer AS T3 ON T3.RootBeerID = T2.RootBeerID WHERE T3.ContainerType = 'Bottle' AND T1.First = 'Jim' AND T1.Last = 'Breech'
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
regional_sales
List out the product name of order which has unit cost of 781.22.
SELECT T FROM ( SELECT DISTINCT IIF(T1.`Unit Cost` = 781.22, T2.`Product Name`, NULL) AS T FROM `Sales Orders` T1 INNER JOIN Products T2 ON T2.ProductID = T1._ProductID ) WHERE T IS NOT NULL
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 ...
sales
Calculate the percentage of sold blades in the total number of transactions.
percentage = MULTIPLY(DIVIDE(SUM(Quantity WHERE Name = 'Blade'), SUM(Quantity)), 1.0); 'blades' refers to name of product;
SELECT CAST(SUM(IIF(T1.Name = 'Blade', T2.Quantity, 0)) AS REAL) * 100 / SUM(T2.Quantity) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID
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...
student_loan
How many students have been absents for more than 6 months?
absents for more than 6 months refers to month > 6
SELECT COUNT(name) FROM longest_absense_from_school WHERE month > 6
CREATE TABLE bool ( "name" TEXT default '' not null primary key ); CREATE TABLE person ( "name" TEXT default '' not null primary key ); CREATE TABLE disabled ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update c...
authors
What is the short name for "Software - Concepts and Tools / Structured Programming"?
'Software - Concepts and Tools / Structured Programming' is the FullName;
SELECT ShortName FROM Journal WHERE FullName = 'Software - Concepts and Tools / Structured Programming'
CREATE TABLE IF NOT EXISTS "Author" ( Id INTEGER constraint Author_pk primary key, Name TEXT, Affiliation TEXT ); CREATE TABLE IF NOT EXISTS "Conference" ( Id INTEGER constraint Conference_pk primary key, ShortName TEXT, FullName TE...
soccer_2016
What is the date of the match that has the highest wager on the final result of a game?
date of the match refers to Match_Date; highest wager refers to max(Win_Margin)
SELECT Match_Date FROM `Match` ORDER BY Win_Margin DESC LIMIT 1
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...
retail_complains
Please list the emails of the clients whose complaint date received is 7/3/2014.
7/3/2014 refers to Date received = '2014-07-03'
SELECT T1.email FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Date received` = '2014-07-03'
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...
food_inspection_2
Give the address of the schools that passed the inspection in March 2010.
school refers to facility_type = 'School'; pass refers to results = 'Pass'; in March 2010 refers to inspection_date like '2010-03%'
SELECT DISTINCT T1.address FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no WHERE strftime('%Y-%m', T2.inspection_date) = '2010-03' AND T2.results = 'Pass' AND T1.facility_type = 'School'
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...
chicago_crime
What is the average number of reckless homicides that happened in a district?
"RECKLESS HOMICIDE" is the secondary_description; average = Divide (Count(report_no), Count(district_name))
SELECT CAST(COUNT(T2.report_no) AS REAL) / COUNT(DISTINCT T1.district_name) FROM District AS T1 INNER JOIN Crime AS T2 ON T2.district_no = T1.district_no INNER JOIN IUCR AS T3 ON T3.iucr_no = T2.iucr_no WHERE T3.secondary_description = 'RECKLESS HOMICIDE'
CREATE TABLE Community_Area ( community_area_no INTEGER primary key, community_area_name TEXT, side TEXT, population TEXT ); CREATE TABLE District ( district_no INTEGER primary key, district_name TEXT, address TEXT, zip_code ...
human_resources
How many employees are there in the "Miami" office?
Miami office refers to locationcity = 'Miami'
SELECT COUNT(*) FROM employee AS T1 INNER JOIN location AS T2 ON T1.locationID = T2.locationID WHERE T2.locationcity = 'Miami'
CREATE TABLE location ( locationID INTEGER constraint location_pk primary key, locationcity TEXT, address TEXT, state TEXT, zipcode INTEGER, officephone TEXT ); CREATE TABLE position ( positionID INTEGER constraint position_pk ...
european_football_1
How many draw games happened on 2018/8/7 for National League?
National League is the name of division; Date = '2018-08-07'; draw refers to FTR = 'D'; games refer to Div;
SELECT COUNT(T1.FTR) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'National League' AND T1.Date = '2018-08-07' AND T1.FTR = 'D'
CREATE TABLE divisions ( division TEXT not null primary key, name TEXT, country TEXT ); CREATE TABLE matchs ( Div TEXT, Date DATE, HomeTeam TEXT, AwayTeam TEXT, FTHG INTEGER, FTAG INTEGER, FTR TEXT, season INTEGER, foreign key (Div) re...
public_review_platform
List the city of the business where they open from 1 pm to 6 pm on Saturday.
1 pm refers to opening_time = '1PM'; 6 pm refers to closing_time = '6PM'; on Saturday refers to day_of_week = 'Saturday'
SELECT T1.city FROM Business AS T1 INNER JOIN Business_Hours AS T2 ON T1.business_id = T2.business_id INNER JOIN Days AS T3 ON T2.day_id = T3.day_id WHERE T2.closing_time LIKE '6PM' AND T2.opening_time LIKE '1PM' AND T3.day_of_week LIKE 'Saturday'
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 ...
university
In 2011, which university got the lowest score in teaching criteria?
in 2011 refers to year 2011; got the lowest score refers to MIN(score), teaching criteria refers to criteria_name = 'Teaching'
SELECT T3.university_name FROM ranking_criteria AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.ranking_criteria_id INNER JOIN university AS T3 ON T3.id = T2.university_id WHERE T1.criteria_name = 'Teaching' AND T2.year = 2011 ORDER BY T2.score ASC 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 ...
student_loan
List out students that enrolled in occ school and enlisted in a fire department.
occ school refers to school = 'occ'; department refers to organ; organ = 'fire_department';
SELECT T1.name FROM enlist AS T1 INNER JOIN enrolled AS T2 ON T2.name = T1.name WHERE T2.school = 'occ' AND T1.organ = 'fire_department'
CREATE TABLE bool ( "name" TEXT default '' not null primary key ); CREATE TABLE person ( "name" TEXT default '' not null primary key ); CREATE TABLE disabled ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update c...
shipping
What is the most populated city in California?
in California refers to state = 'CA'; most populated city refers to Max(population)
SELECT city_name FROM city WHERE state = 'California' AND population = ( SELECT MAX(population) FROM city WHERE state = 'California' )
CREATE TABLE city ( city_id INTEGER primary key, city_name TEXT, state TEXT, population INTEGER, area REAL ); CREATE TABLE customer ( cust_id INTEGER primary key, cust_name TEXT, annual_revenue INTEGER, cust_type TEXT, addre...
video_games
State the game publisher IDs of the games with a platform ID of 16.
SELECT T.game_publisher_id FROM game_platform AS T WHERE T.platform_id = 16
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...
university
Give the score and number of international students in university ID 100 in 2015.
number of international students refers to DIVIDE(MULTIPLY(num_students, pct_international_students), 100); in 2015 refers to year = 2015
SELECT CAST(T1.num_students * T1.pct_international_students AS REAL) / 100, T2.score FROM university_year AS T1 INNER JOIN university_ranking_year AS T2 ON T1.university_id = T2.university_id WHERE T2.year = 2015 AND T1.university_id = 100
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 ...
hockey
How many former athletes go on to become coaches after retiring?
SELECT COUNT(playerID) FROM Master WHERE playerID IS NOT NULL AND coachID IS NOT NULL
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 ...
retails
How many customers in the machinery segment are in debt?
machinery segment refers to c_mktsegment = 'MACHINERY'; in debt refers to c_acctbal < 0
SELECT COUNT(c_custkey) FROM customer WHERE c_acctbal < 0 AND c_mktsegment = 'MACHINERY'
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`),...
talkingdata
Provide the number of events that happened on 2016/5/6.
on 2016/5/6 refers to timestamp = '2016/5/6 XX:XX:XX';
SELECT COUNT(event_id) FROM events WHERE SUBSTR(`timestamp`, 1, 10) = '2016-05-06'
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...
cs_semester
What is the phone number of Kerry Pryor?
SELECT phone_number FROM student WHERE l_name = 'Pryor' AND f_name = 'Kerry'
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...
legislator
What is the ratio of males and females among historical legislators?
male refers to gender_bio = 'M'; female refers to gender_bio = 'F'; calculation = DIVIDE(COUNT(gender_bio = 'M' THEN bioguide_id), COUNT(gender_bio = 'F' THEN bioguide_id))
SELECT CAST(SUM(CASE WHEN gender_bio = 'M' THEN 1 ELSE 0 END) AS REAL) / SUM(CASE WHEN gender_bio = 'F' THEN 1 ELSE 0 END) FROM historical
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 ...
movies_4
How many animators does Movie No. 129 have?
animators refers to job = 'Animation'; Movie No. 129 refers to movie_id = 129
SELECT COUNT(movie_id) FROM movie_crew WHERE movie_id = 129 AND job = 'Animation'
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 ( ...
donor
What is the average unit price of AKJ Books items?
AKJ Books items refers to vendor_name = 'AKJ Books'; average unit price refers to DIVIDE(sum(item_unit_price),count(resourceid))
SELECT SUM(item_unit_price) / SUM(item_quantity) FROM resources WHERE vendor_name = 'AKJ Books'
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
What is the gender of the user who has posted the tweet that got the most likes?
tweet got the most likes refers to Max(Likes)
SELECT T2.Gender FROM twitter AS T1 INNER JOIN user AS T2 ON T1.UserID = T2.UserID ORDER BY T1.Likes 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 ( ...
retails
Provide the nation and region of the customer with the address of wH55UnX7 VI?
nation refers to n_name; region refers to r_name; address of wH55UnX7 VI refers to c_address = 'wH55UnX7 VI';
SELECT T1.n_name, T3.r_name FROM nation AS T1 INNER JOIN customer AS T2 ON T1.n_nationkey = T2.c_nationkey INNER JOIN region AS T3 ON T1.n_regionkey = T3.r_regionkey WHERE T2.c_address = 'wH55UnX7 VI'
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`),...
synthea
Calculate the number of female patients who accepted "HPV quadrivalent" immunization.
female refers to gender = 'F'; "HPV quadrivalent" immunization refers to immunizations where DESCRIPTION = 'HPV quadrivalent';
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN immunizations AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'HPV quadrivalent' AND T1.gender = 'F'
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 ...
restaurant
What percentage of restaurants are from the Bay Area?
Bay Area refers to region = 'bay area'; percentage = divide(count(id_restaurant where region = 'bay area'), count(id_restaurant)) * 100%
SELECT CAST(SUM(IIF(T1.region = 'bay area', 1, 0)) AS REAL) * 100 / COUNT(T2.id_restaurant) FROM geographic AS T1 INNER JOIN location AS T2 ON T1.city = T2.city
CREATE TABLE geographic ( city TEXT not null primary key, county TEXT null, region TEXT null ); CREATE TABLE generalinfo ( id_restaurant INTEGER not null primary key, label TEXT null, food_type TEXT null, city TEXT null, review REA...
music_tracker
What are the top 5 tags with the highest amount of downloads?
the highest amount of downloads refers to MAX(totalSnatched);
SELECT T2.tag FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T1.releaseType = 'album' ORDER BY T1.totalSnatched DESC LIMIT 5
CREATE TABLE IF NOT EXISTS "torrents" ( groupName TEXT, totalSnatched INTEGER, artist TEXT, groupYear INTEGER, releaseType TEXT, groupId INTEGER, id INTEGER constraint torrents_pk primary key ); CREATE TABLE IF NOT EXISTS "tags" ( "in...
software_company
Of the first 60,000 customers who sent a true response to the incentive mailing sent by the marketing department, how many of them are from a place with more than 30,000 inhabitants?
RESPONSE = 'true'; place with more than 30,000 inhabitants refers to GEOID where INHABITANTS_K > 30;
SELECT COUNT(T1.ID) FROM Customers AS T1 INNER JOIN Mailings1_2 AS T2 ON T1.ID = T2.REFID INNER JOIN Demog AS T3 ON T1.GEOID = T3.GEOID WHERE T3.INHABITANTS_K > 30 AND T2.RESPONSE = 'true'
CREATE TABLE Demog ( GEOID INTEGER constraint Demog_pk primary key, INHABITANTS_K REAL, INCOME_K REAL, A_VAR1 REAL, A_VAR2 REAL, A_VAR3 REAL, A_VAR4 REAL, A_VAR5 REAL, A_VAR6 REAL, A_VAR7 REAL, ...
movie_platform
Please list the names of the top three movies in the number comments related to the critic made by the user rating the movie.
number of comments related to the critic made by the user rating the movie refers to critic_comments; top movie refers to Max(critic_comments);
SELECT T2.movie_title FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id ORDER BY T1.critic_comments DESC LIMIT 3
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...
beer_factory
Among the root beer brands that do not advertise on Twitter, how many of them have root beers sold in August, 2014?
do not advertise on Twitter refers to twitter IS NULL; in August, 2014 refers to SUBSTR(TransactionDate, 1, 4) = '2014' AND SUBSTR(TransactionDate, 6, 2) = '08';
SELECT COUNT(T1.BrandID) FROM rootbeer AS T1 INNER JOIN `transaction` AS T2 ON T1.RootBeerID = T2.RootBeerID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID WHERE T2.TransactionDate LIKE '2014-08%' AND T3.Twitter IS NULL
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
regional_sales
State all the order numbers for sales team of Samuel Fowler.
SELECT T FROM ( SELECT DISTINCT CASE WHEN T2.`Sales Team` = 'Samuel Fowler' THEN T1.OrderNumber ELSE NULL END AS T FROM `Sales Orders` T1 INNER JOIN `Sales Team` T2 ON T2.SalesTeamID = T1._SalesTeamID ) WHERE T IS NOT NULL
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 ...
works_cycles
Please list the top 3 house-manufactured products with the highest average rating.
home manufactured refers to MakeFlag = 1; average rating = divide(sum(Rating), count(ProductReview))
SELECT T2.Name FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.MakeFlag = 1 GROUP BY T2.Name ORDER BY SUM(T1.Rating) 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 ...
address
What is the bad alias of the residential area with the highest average house value?
highest average house value refers to Max(avg_house_value)
SELECT T2.bad_alias FROM zip_data AS T1 INNER JOIN avoid AS T2 ON T1.zip_code = T2.zip_code WHERE T1.avg_house_value = ( SELECT MAX(avg_house_value) FROM zip_data ) LIMIT 1
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 ...
airline
How many planes of Spirit Air Lines took off on 2018/8/7?
Spirit Air Lines refers to Description = 'Spirit Air Lines: NK'; on 2018/8/7 refers to FL_DATE = '2018/8/7';
SELECT COUNT(T2.Code) FROM Airlines AS T1 INNER JOIN `Air Carriers` AS T2 ON T1.OP_CARRIER_AIRLINE_ID = T2.Code WHERE T1.FL_DATE = '2018/8/7' AND T2.Description = 'Spirit Air Lines: NK'
CREATE TABLE IF NOT EXISTS "Air Carriers" ( Code INTEGER primary key, Description TEXT ); CREATE TABLE Airports ( Code TEXT primary key, Description TEXT ); CREATE TABLE Airlines ( FL_DATE TEXT, OP_CARRIER_AIRLINE_ID INTEGER, TAIL_NUM ...
world
Give the cities and district names that belong to the country with Hajastan as its local name.
SELECT T2.Name, T2.District FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode WHERE T1.LocalName = 'Hajastan'
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...
disney
How many movies for mature audiences or parental guidance suggested did Bill Thompson work as a voice actor?
movies for mature audiences or parental guidance refer to movie_title where MPAA_rating = 'PG';
SELECT COUNT(T.movie) FROM ( SELECT T1.movie FROM `voice-actors` AS T1 INNER JOIN movies_total_gross AS T2 ON T1.movie = T2.movie_title WHERE MPAA_rating = 'PG' AND `voice-actor` = 'Bill Thompson' GROUP BY T1.movie ) AS T
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...
beer_factory
Please name all of the cities in California.
California refers to State = 'CA';
SELECT DISTINCT City FROM customers WHERE State = 'CA'
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
soccer_2016
How many first teams chose to bat after winning the toss?
first teams refers to Team_1; chose to bat after winning the toss refers to Toss_Winner and Toss_Decide = 2
SELECT COUNT(Team_1) FROM `Match` WHERE Team_1 = Toss_Winner AND Toss_Decide = 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...
professional_basketball
What is the maximum weight of USA all-star players?
"USA" is the birthCountry of player;  maximum weight refers to Max(weight)
SELECT MAX(T1.weight) FROM players AS T1 INNER JOIN player_allstar AS T2 ON T1.playerID = T2.playerID WHERE T1.birthCountry = 'USA'
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
Among the matches in 2013, what is the percentage of winning of the team "Mumbai Indians"?
in 2013 refers to Match_Date like '2013%'; winning of the team "Mumbai Indians" refers to Match_Winner = 7; percentage refers to DIVIDE(COUNT(Match_Winner = 7), COUNT(Match_Winner))
SELECT CAST(SUM(CASE WHEN T2.Match_Winner = 7 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.Match_Winner) FROM Team AS T1 INNER JOIN Match AS T2 ON T1.Team_Id = T2.Match_Winner WHERE T2.Match_Date LIKE '2013%'
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...
books
How many books did A.R. Braunmuller write?
"A.R. Braunmuller" is the author_name
SELECT COUNT(*) FROM author AS T1 INNER JOIN book_author AS T2 ON T1.author_id = T2.author_id WHERE T1.author_name = 'A.R. Braunmuller'
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...
authors
List all the titles and their publishing journals from the 60's.
from the 60’s refer to Year 1960 BETWEEN 1970
SELECT T1.Title, T1.JournalId FROM Paper AS T1 INNER JOIN Journal AS T2 ON T1.JournalId = T2.Id WHERE T1.Year >= 1960 AND T1.Year <= 1970
CREATE TABLE IF NOT EXISTS "Author" ( Id INTEGER constraint Author_pk primary key, Name TEXT, Affiliation TEXT ); CREATE TABLE IF NOT EXISTS "Conference" ( Id INTEGER constraint Conference_pk primary key, ShortName TEXT, FullName TE...
movie_platform
What is the percentage of rated movies were released in year 2021?
percentage = DIVIDE(SUM(movie_release_year = 2021), COUNT(rating_id)) as percent; movies released in year 2021 refers to movie_release_year = 2021;
SELECT CAST(SUM(CASE WHEN T1.movie_release_year = 2021 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM movies AS T1 INNER JOIN ratings AS T2 ON T1.movie_id = T2.movie_id
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...
world
What is the GNP of the least crowded city in the world?
least crowded city refers to MIN(Population);
SELECT T2.GNP FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code ORDER BY T1.Population ASC LIMIT 1
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...
food_inspection
List the eateries' names and addresses which had reinspection on 2nd February, 2015.
eateries which had reinspection on 2nd February, 2015 refer to business_id where date = '2015-02-02' and type = 'Reinspection/Followup';
SELECT T2.name, T2.address FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.`date` = '2015-02-02' AND T1.type = 'Reinspection/Followup'
CREATE TABLE `businesses` ( `business_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `address` TEXT DEFAULT NULL, `city` TEXT DEFAULT NULL, `postal_code` TEXT DEFAULT NULL, `latitude` REAL DEFAULT NULL, `longitude` REAL DEFAULT NULL, `phone_number` INTEGER DEFAULT NULL, `tax_code` TEXT DEFAULT NULL, `b...
food_inspection_2
Calculate the average inspections per year done by Jessica Anthony from 2010 to 2017.
from 2010 to 2017 refers to inspection_date > '2010-01-01' AND T2.inspection_id < '2017-12-31'; average inspections per year = divide(count(inspection_id where inspection_date > '2010-01-01' AND T2.inspection_id < '2017-12-31'), 8)
SELECT CAST(COUNT(CASE WHEN T1.first_name = 'Jessica' AND T1.last_name = 'Anthony' THEN T2.inspection_id ELSE 0 END) AS REAL) / 8 FROM employee AS T1 INNER JOIN inspection AS T2 ON T1.employee_id = T2.employee_id WHERE strftime('%Y', T2.inspection_date) BETWEEN '2010' AND '2017'
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...
professional_basketball
For the player who had the most rebounds throughout his allstar appearances, what was his weight and height?
the most rebounds refers to max(rebounds)
SELECT T1.weight, T1.height FROM players AS T1 INNER JOIN player_allstar AS T2 ON T1.playerID = T2.playerID ORDER BY T2.rebounds DESC LIMIT 1
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...
food_inspection
How many of the businesses are located at 1825 POST St #223, San Francisco?
1825 POST St #223 refers to address = '1825 POST St #223', San Francisco is the name of the city;
SELECT COUNT(business_id) FROM businesses WHERE address = '1825 POST St #223' AND city = 'SAN FRANCISCO'
CREATE TABLE `businesses` ( `business_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `address` TEXT DEFAULT NULL, `city` TEXT DEFAULT NULL, `postal_code` TEXT DEFAULT NULL, `latitude` REAL DEFAULT NULL, `longitude` REAL DEFAULT NULL, `phone_number` INTEGER DEFAULT NULL, `tax_code` TEXT DEFAULT NULL, `b...
ice_hockey_draft
How many games did the tallest player have ever played?
tallest player refers to MAX(height_in_cm);
SELECT T1.GP FROM SeasonStatus AS T1 INNER JOIN PlayerInfo AS T2 ON T1.ELITEID = T2.ELITEID WHERE T2.ELITEID = ( SELECT t.ELITEID FROM PlayerInfo t ORDER BY t.height DESC 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...
movie_platform
Between 1/1/2017 to 12/31/2017, how many users who were eligible for trial when they rated the movie "Patti Smith: Dream of Life"and what is the image URL to the movie on Mubi?
Between 1/1/2017 to 12/31/2017 refers to rating_timestamp_utc between '2017-01-01 00:00:00' and '2017-12-31 00:00:00'; eligible for trial refers to user_eligible_for_trial = 1; movie "Patti Smith: Dream of Life" refers to movie_title = 'Patti Smith: Dream of Life'
SELECT COUNT(T1.user_id), T2.movie_image_url FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE datetime(T1.rating_timestamp_utc) BETWEEN '2017-01-01 00:00:00' AND '2017-12-31 00:00:00'
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...
retails
Find and list the part key of the parts which has an above-average retail price.
part key of the parts which has an above-average retail price refer to p_partkey where p_retailprice > AVG(p_retailprice);
SELECT p_partkey FROM part WHERE p_retailprice > ( SELECT AVG(p_retailprice) FROM part )
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`),...
works_cycles
What is the pay rate of the employee who has the longest vacation hours?
longest vacation hour refers to max(VacationHours)
SELECT T1.Rate FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T2.VacationHours 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 ...
regional_sales
State the customer name of orders which has shipped date in 7/8/2018.
shipped date in 7/8/2018 refers to ShipDate = '7/8/18'
SELECT T FROM ( SELECT DISTINCT CASE WHEN T2.ShipDate = '7/8/18' THEN T1.`Customer Names` END AS T FROM Customers T1 INNER JOIN `Sales Orders` T2 ON T2._CustomerID = T1.CustomerID ) WHERE T IS NOT NULL
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 ...
mondial_geo
Please list the countries that share the shortest border.
SELECT T1.Name FROM country AS T1 INNER JOIN borders AS T2 ON T1.Code = T2.Country1 ORDER BY T2.Length ASC LIMIT 1
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...
retail_world
List out the phone number of the shipping company of order id 10296.
shipping company refers to Shippers; phone number refers to Phone
SELECT T2.Phone FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T1.OrderID = 10260
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, ...
human_resources
How many "account representatives" are there in Chicago with a good performance?
account representatives is a position title; Chicago refers to locationcity = 'Chicago'; good performance refers to performance = 'Good'
SELECT COUNT(*) FROM employee AS T1 INNER JOIN location AS T2 ON T1.locationID = T2.locationID INNER JOIN position AS T3 ON T3.positionID = T1.positionID WHERE T3.positiontitle = 'Account Representative' AND T2.locationcity = 'Chicago' AND T1.performance = 'Good'
CREATE TABLE location ( locationID INTEGER constraint location_pk primary key, locationcity TEXT, address TEXT, state TEXT, zipcode INTEGER, officephone TEXT ); CREATE TABLE position ( positionID INTEGER constraint position_pk ...
olympics
What is the game name that was held in Beijing in 2008?
Beijing refers to city_name = 'Beijing'; in 2008 refers to games_year = '2008';
SELECT T3.games_name FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id INNER JOIN games AS T3 ON T1.games_id = T3.id WHERE T2.city_name = 'Beijing' AND T3.games_year = 2008
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...
retail_complains
Calculate the average age of clients whose response is "Closed with relief".
average age = avg(age where Company response to consumer = 'Closed with relief'); response "Closed with relief" refers to Company response to consumer = 'Closed with relief'
SELECT AVG(T1.age) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Company response to consumer` = 'Closed with relief'
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...
public_review_platform
How many businesses ID sell beer and wine?
attribute_value = 'beer_and_wine'
SELECT COUNT(business_id) FROM Business_Attributes WHERE attribute_id = 1 AND attribute_value = 'beer_and_wine'
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 ...
mondial_geo
What are the names of the sea that can be found on the island with the biggest area?
SELECT T2.Name FROM islandIn AS T1 INNER JOIN sea AS T2 ON T2.Name = T1.Sea WHERE T1.Island = ( SELECT Name FROM island ORDER BY Area DESC LIMIT 1 )
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...
software_company
List down the geographic identifier with an number of inhabitants less than 30.
geographic identifier with an number of inhabitants less than 30 refers to GEOID where INHABITANTS_K < 30;
SELECT GEOID FROM Demog WHERE INHABITANTS_K < 30
CREATE TABLE Demog ( GEOID INTEGER constraint Demog_pk primary key, INHABITANTS_K REAL, INCOME_K REAL, A_VAR1 REAL, A_VAR2 REAL, A_VAR3 REAL, A_VAR4 REAL, A_VAR5 REAL, A_VAR6 REAL, A_VAR7 REAL, ...
european_football_1
What's the winning rate of Club Brugge in the 2021 Premier League?
Premier League is name of division; season = 2021; Club Brugge is name of team; Club Brugge wins implies HomeTeam = 'Club Brugge' and FTR = 'H' and AwayTeam = 'Club Brugge' and FTR = 'A'; DIVIDE(SUM(COUNT(FTR = 'H' where HomeTeam = 'Club Brugge', name = 'Premier League', season = 2021), COUNT(FTR = 'A'where AwayTeam = ...
SELECT CAST(COUNT(CASE WHEN T1.FTR = 'H' THEN 1 ELSE NULL END) + COUNT(CASE WHEN T1.FTR = 'A' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(t1.FTR) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.season = 2021 AND T1.AwayTeam = 'Club Brugge' OR T1.HomeTeam = 'Club Brugge'
CREATE TABLE divisions ( division TEXT not null primary key, name TEXT, country TEXT ); CREATE TABLE matchs ( Div TEXT, Date DATE, HomeTeam TEXT, AwayTeam TEXT, FTHG INTEGER, FTAG INTEGER, FTR TEXT, season INTEGER, foreign key (Div) re...
human_resources
State the name of the city where Jose Rodriguez works.
Jose Rodriguez is the fullname of an employee; full name = firstname, lastname; name of city refers to locationcity
SELECT T2.locationcity FROM employee AS T1 INNER JOIN location AS T2 ON T1.locationID = T2.locationID WHERE T1.firstname = 'Jose' AND T1.lastname = 'Rodriguez'
CREATE TABLE location ( locationID INTEGER constraint location_pk primary key, locationcity TEXT, address TEXT, state TEXT, zipcode INTEGER, officephone TEXT ); CREATE TABLE position ( positionID INTEGER constraint position_pk ...
movies_4
How many Indian movies between 1/2/1990 and 12/30/2003 have revenue of more than 75,000,000 and popularity of no less than 20?
Indian movies refers to country_name = 'India'; between 1/2/1990 and 12/30/2003 refers to release_date BETWEEN '1990-01-02' AND '2003-12-30'; revenue of more than 75,000,000 refers to revenue > 75000000; popularity of no less than 20 refers to popularity > = 20
SELECT COUNT(T2.movie_id) FROM movie AS T1 INNER JOIN production_COUNTry AS T2 ON T1.movie_id = T2.movie_id WHERE T1.revenue > 75000000 AND T1.popularity >= 20 AND T1.release_date BETWEEN '1990-01-01' AND '2003-12-31'
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 ( ...
works_cycles
Please provide contact details of all Marketing Managers. State their name and phone number.
Marketing Manager is a job title
SELECT T1.FirstName, T1.LastName, T2.PhoneNumber FROM Person AS T1 INNER JOIN PersonPhone AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Employee AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T3.JobTitle = 'Marketing Manager'
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 ...
regional_sales
In the West, how many stores are there in the city whose land area is below 20,000,000?
"West" is the Region; land area is below 20,000,000 refers to Land Area < 20,000,000
SELECT SUM(CASE WHEN T1.Region = 'West' AND T2.`Land Area` < 20000000 THEN 1 ELSE 0 END) FROM Regions AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StateCode = T1.StateCode
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 ...
professional_basketball
For the 2001 rebounds leader in the league, when was his birthday?
2001 refers to year = 2001; rebounds leader refers to max(rebounds); birthday refers to birthDate
SELECT birthDate FROM players WHERE playerID = ( SELECT playerID FROM players_teams WHERE year = 2001 GROUP BY playerID ORDER BY SUM(rebounds + dRebounds) DESC LIMIT 1 )
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...
music_tracker
What are the tags of the release "sugarhill gang"?
release "sugarhill gang" refers to groupName = 'sugarhill gang';
SELECT T2.tag FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T1.groupName = 'sugarhill gang'
CREATE TABLE IF NOT EXISTS "torrents" ( groupName TEXT, totalSnatched INTEGER, artist TEXT, groupYear INTEGER, releaseType TEXT, groupId INTEGER, id INTEGER constraint torrents_pk primary key ); CREATE TABLE IF NOT EXISTS "tags" ( "in...
retails
What was the order date of items with the highest total price?
the highest total price refers to MAX(o_totalprice);
SELECT o_orderdate FROM orders WHERE o_totalprice = ( SELECT MAX(o_totalprice) FROM orders )
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`),...
synthea
Give the social security number of the female Irish patient allergic to grass pollen.
social security number refers to ssn; female refers to gender = 'F'; Irish refers to ethnicity = 'irish'; allergic to grass pollen refers to allergies where DESCRIPTION = 'Allergy to grass pollen';
SELECT T2.ssn FROM allergies AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.DESCRIPTION = 'Allergy to grass pollen' AND T2.ethnicity = 'irish' AND T2.gender = 'F'
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 ...