db_id
stringclasses
69 values
question
stringlengths
24
325
evidence
stringlengths
0
673
SQL
stringlengths
23
804
schema
stringclasses
69 values
retail_world
What products are no longer sold by Northwind?
no longer sold refers to Discontinued = 1; products refers to ProductName
SELECT ProductName FROM Products WHERE Discontinued = 1
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, ...
superstore
Calculate the total profit by Cisco SPA301 for all regions.
Cisco SPA301' is the "Product Name"; all regions refers to central_superstore, south_superstore, west_superstore, east_superstore
SELECT SUM(T1.Profit) + SUM(T2.Profit) + SUM(T3.Profit) + SUM(T4.Profit) AS totalProfit FROM west_superstore AS T1 INNER JOIN east_superstore AS T2 ON T1.`Customer ID` = T2.`Customer ID` INNER JOIN central_superstore AS T3 ON T3.`Customer ID` = T2.`Customer ID` INNER JOIN south_superstore AS T4 ON T4.`Customer ID` = T3...
CREATE TABLE people ( "Customer ID" TEXT, "Customer Name" TEXT, Segment TEXT, Country TEXT, City TEXT, State TEXT, "Postal Code" INTEGER, Region TEXT, primary key ("Customer ID", Region) ); CREATE TABLE product ( "Product ID" TE...
movie_platform
What's the number of the paying subscribers when rating a movie after the year 2014?
paying subscribers refers to user_has_payment_method = 1; rating a movie after the year 2014 refers to rating_date_utc>'2014%'
SELECT COUNT(user_subscriber) FROM ratings_users WHERE user_has_payment_method = 1 AND rating_date_utc > '2014%'
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...
olympics
State the number of athletes in the 1984 Summer Olympic Games who were more than 50 years old.
the 1984 Summer Olympic Games refer to games_name = '1984 Summer'; athletes more than 50 years old refer to person_id where age > 50;
SELECT COUNT(T2.person_id) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id WHERE T1.games_name = '1984 Summer' AND T2.age > 50
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...
trains
What is the shape of the tail car on train no.1?
train no.1 refers to train_id = 1; tail car refers to position = 4
SELECT shape FROM cars WHERE train_id = 1 AND position = 4
CREATE TABLE `cars` ( `id` INTEGER NOT NULL, `train_id` INTEGER DEFAULT NULL, `position` INTEGER DEFAULT NULL, `shape` TEXT DEFAULT NULL, `len`TEXT DEFAULT NULL, `sides` TEXT DEFAULT NULL, `roof` TEXT DEFAULT NULL, `wheels` INTEGER DEFAULT NULL, `load_shape` TEXT DEFAULT NULL, `load_num` INTEGER DEF...
retail_complains
Among the calls from California, what percentage are priority 1?
California refers to state = 'California'; percentage = MULTIPLY(DIVIDE(SUM(priority = 1), COUNT("Complaint ID"), 1.0));
SELECT CAST(SUM(CASE WHEN T1.priority = 1 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.priority) FROM callcenterlogs AS T1 INNER JOIN client AS T2 ON T1.`rand client` = T2.client_id INNER JOIN district AS T3 ON T2.district_id = T3.district_id INNER JOIN state AS T4 ON T3.state_abbrev = T4.StateCode WHERE T4.State = 'Ca...
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...
music_platform_2
Please list the titles of all the podcasts under the category "arts-performing-arts".
category 'arts-performing-arts' refers to category = 'arts-performing-arts';
SELECT DISTINCT T2.title FROM categories AS T1 INNER JOIN podcasts AS T2 ON T2.podcast_id = T1.podcast_id WHERE T1.category = 'arts-performing-arts'
CREATE TABLE runs ( run_at text not null, max_rowid integer not null, reviews_added integer not null ); CREATE TABLE podcasts ( podcast_id text primary key, itunes_id integer not null, slug text not null, itunes_url text not null, title text not null ...
retail_world
How many non-discontinued products are there in the dairy category?
non-discontinued products in the dairy category refer to ProductID where Discontinued = 0 and CategoryName = 'Dairy Products';
SELECT COUNT(T1.CategoryID) FROM Categories AS T1 INNER JOIN Products AS T2 ON T1.CategoryID = T2.CategoryID WHERE T1.CategoryName = 'Dairy Products' AND T2.Discontinued = 0
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 is the total occurrence of the biwords pairs with "àbac" as its first word?
occurrence refers to occurrences; àbac refers to word = 'àbac'; first word refers to w1st
SELECT COUNT(T2.w1st) FROM words AS T1 INNER JOIN biwords AS T2 ON T1.wid = T2.w1st INNER JOIN words AS T3 ON T3.wid = T2.w2nd WHERE T1.word = 'àbac'
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...
app_store
Which apps have multiple genres and what is the total sentiment subjectivity of these apps?
multiple genres refers to COUNT(Genres>1; total sentiment subjectivity = Sum(Sentiment_Subjectivity);
SELECT SUM(T2.Sentiment_Subjectivity) FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.Genres > 1
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...
works_cycles
How many products are out of stock?
out of stock product refers to OnOrderQty = 0;
SELECT COUNT(ProductID) FROM ProductVendor WHERE OnOrderQty = 0
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 ...
retails
In which country do most of the customers come from?
country refers to n_name; most of the customers refer to MAX(COUNT(c_custkey));
SELECT T.n_name FROM ( SELECT T2.n_name, COUNT(T1.c_custkey) AS num FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey GROUP BY T2.n_name ) AS T ORDER BY T.num DESC LIMIT 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`),...
chicago_crime
What is the FBI code and definition of Gambling?
FBI code refers to fbi_code_no; definition refers to description; Gambling refers to title = 'Gambling'
SELECT fbi_code_no, description FROM FBI_Code WHERE title = 'Gambling'
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 ...
codebase_comments
What is the github address of the solution path "joeyrobert_bloomfilter\DataTypes.BloomFilter.sln"?
github address refers to Url; solution path refers to Path; Path = 'joeyrobert_bloomfilter\DataTypes.BloomFilter.sln';
SELECT T1.Url FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T2.Path = 'joeyrobert_bloomfilterDataTypes.BloomFilter.sln'
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...
works_cycles
Among the employees in the Manufacturing group in 2007, how many of them are store contacts?
store contact refers to PersonType = 'SC'; year(EndDate)>2007 and year(StartDate)<2007;
SELECT COUNT(T1.BusinessEntityID) FROM EmployeeDepartmentHistory AS T1 INNER JOIN Department AS T2 ON T1.DepartmentID = T2.DepartmentID INNER JOIN Person AS T3 ON T1.BusinessEntityID WHERE T3.PersonType = 'SC' AND T2.GroupName = 'Manufacturing' AND STRFTIME('%Y', T1.EndDate) >= '2007' AND STRFTIME('%Y', T1.StartDate) <...
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 ...
bike_share_1
Which city is Townsend at 7th Station located and how many bikes could it hold?
Townsend at 7th Station refers to city = 'Townsend at 7th Station'; number of bikes a station can hold refers to SUM(dock_count);
SELECT city, SUM(dock_count) FROM station WHERE name = 'Townsend at 7th'
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...
image_and_language
Indicate the bounding box of the image 8.
bounding box refers to X, Y, W, H from IMG_OBJ; image 8 refers to IMG_ID = 8;
SELECT X, Y, W, H FROM IMG_OBJ WHERE IMG_ID = 8
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...
sales
What is the name of the most expensive product?
most expensive product refers to MAX(Price);
SELECT Name FROM Products WHERE Price = ( SELECT MAX(Price) FROM Products )
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...
mental_health_survey
How many users answered the question No.20?
question No.20 refers to QuestionID = 20
SELECT MAX(UserID) - MIN(UserID) + 1 FROM Answer WHERE QuestionID = 20
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...
movielens
UK produced what genre of movies?
UK is a country
SELECT T2.genre FROM movies AS T1 INNER JOIN movies2directors AS T2 ON T1.movieid = T2.movieid WHERE T1.country = 'UK'
CREATE TABLE users ( userid INTEGER default 0 not null primary key, age TEXT not null, u_gender TEXT not null, occupation TEXT not null ); CREATE TABLE IF NOT EXISTS "directors" ( directorid INTEGER not null primary key, d_quality INTEGER not null, avg...
talkingdata
What are the categories of the top 2 oldest events?
oldest event refers to MIN(timestamp);
SELECT T4.category FROM events_relevant AS T1 INNER JOIN app_events_relevant AS T2 ON T1.event_id = T2.event_id INNER JOIN app_labels AS T3 ON T3.app_id = T2.app_id INNER JOIN label_categories AS T4 ON T3.label_id = T4.label_id ORDER BY T1.timestamp LIMIT 2
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
What is the rating of Dragon Ball Legends and how many users dislike this App?
Dragon Ball Legends is the app; users who dislikes the app refers to Sentiment_Polarity<-0.5;
SELECT T1.Rating, COUNT(T2.Sentiment_Polarity) FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.App = 'Dragon Ball Legends' AND CAST(Sentiment_Polarity AS INTEGER) < -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...
retails
Of the orders with a lower delivery priority, how many have an urgent priority order?
an urgent priority order refers to o_orderkey where o_orderpriority = '1-URGENT'; earlier orderdate have higher priority in delivery; lower delivery priority refers to MAX(o_orderdate);
SELECT COUNT(o_orderkey) FROM orders WHERE o_orderpriority = '1-URGENT' GROUP BY o_orderdate ORDER BY o_orderdate DESC LIMIT 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`),...
works_cycles
What is contact Type ID No.16 represent for?
SELECT Name FROM ContactType WHERE ContactTypeID = '16'
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 ...
restaurant
What is the name of the most popular restaurant serving Asian foods in San Francisco?
the most popular refers to max(review); Asian food refers to food_type = 'asian'; San Francisco refers to city = 'san francisco'
SELECT label FROM generalinfo WHERE food_type = 'asian' AND city = 'san francisco' AND review = ( SELECT MAX(review) FROM generalinfo WHERE food_type = 'asian' AND city = 'san francisco' )
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...
car_retails
List all customer names with orders that are disputed.
Orders that are disputed refer to status = 'Disputed'; the sales representative means employees; names refers to firstName, lastName.
SELECT t3.firstName, t3.lastName FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber INNER JOIN employees AS t3 ON t2.salesRepEmployeeNumber = t3.employeeNumber WHERE t1.status = 'Disputed'
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...
hockey
Who are the players played both in NHL and WHA. List the given name and first year they were in NHL and first year in WHA.
first year they were in NHL refers to firstNHL; first year in WHA refers to firstWHA; play in both refers to firstNHL IS NOT NULL AND firstWHA IS NOT NULL
SELECT nameGiven, firstNHL, firstWHA FROM Master WHERE firstNHL IS NOT NULL AND firstWHA 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 ...
student_loan
Provide the students' names and schools who enrolled for 15 months.
enrolled for 15 months refers to month = 15;
SELECT name, school FROM enrolled WHERE month = 15
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...
professional_basketball
In 1937, how many teams whose players got at least 500 points?
in 1937 refers to year = 1937; player got at least 500 points refers to Sum(points) > = 500
SELECT COUNT(*) FROM ( SELECT T2.name, SUM(T1.points) FROM players_teams AS T1 INNER JOIN teams AS T2 ON T1.tmID = T2.tmID AND T1.year = T2.year WHERE T1.year = 1937 GROUP BY T2.name HAVING SUM(points) >= 500 ) AS T3
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...
airline
List the flight date of flights with air carrier described as Profit Airlines Inc.: XBH which have an actual elapsed time below 100.
flight date refers to FL_DATE; Profit Airlines Inc.: XBH refers to Description = 'Profit Airlines Inc.: XBH'; actual elapsed time below 100 refers to ACTUAL_ELAPSED_TIME < 100;
SELECT T2.FL_DATE FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T2.ACTUAL_ELAPSED_TIME < 100 AND T1.Description = 'Profit Airlines Inc.: XBH'
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_development_indicators
How many nations in East Asia and the Pacific have completed their external debt reporting on time?
in East Asia and the Pacific refers to region = 'East Asia & Pacific'; have completed their external debt reporting on time refers to ExternalDebtReportingStatus = 'Estimate'
SELECT COUNT(CountryCode) FROM Country WHERE Region = 'East Asia & Pacific' AND ExternalDebtReportingStatus = 'Estimate'
CREATE TABLE IF NOT EXISTS "Country" ( CountryCode TEXT not null primary key, ShortName TEXT, TableName TEXT, LongName TEXT, Alpha2Code ...
law_episode
How many people did not enjoy the finale episode?
did not enjoy refers to stars = 1; the finale episode refers to episode = 24
SELECT COUNT(T1.episode_id) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T1.episode = 24 AND T2.stars = 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 ...
professional_basketball
Among the teams that were ranked 3 from 1937 to 1940, what is the team name whose players had the highest point?
from 1937 to 1940 refers to year between 1937 and 1940; player with highest point refers to Max(points)
SELECT DISTINCT T1.name FROM teams AS T1 INNER JOIN players_teams AS T2 ON T1.tmID = T2.tmID AND T1.year = T2.year WHERE T1.rank = 3 AND T1.year BETWEEN 1937 AND 1940 ORDER BY T2.points 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...
authors
Please provide the titles of any two papers that are either preprinted or unpublished along with the full name of the journal to which those papers belong.
papers that are either preprinted or unpublished along refers to Year = 0
SELECT T1.Title, T2.FullName FROM Paper AS T1 INNER JOIN Journal AS T2 ON T1.JournalId = T2.Id WHERE T1.Year < 1 LIMIT 2
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...
books
What is the sum of the number of pages of the books ordered by Mick Sever?
sum of the number of pages refers to Sum(num_pages)
SELECT SUM(T1.num_pages) FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id INNER JOIN cust_order AS T3 ON T3.order_id = T2.order_id INNER JOIN customer AS T4 ON T4.customer_id = T3.customer_id WHERE T4.first_name = 'Mick' AND T4.last_name = 'Sever'
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...
language_corpus
Indicate which is the word that is repeated the most times.
repeated the most times refer to MAX(occurrences);
SELECT word FROM words WHERE occurrences = ( SELECT MAX(occurrences) FROM words )
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...
hockey
Name the deceased players whose death country is different from his birth country order by birth year.
death country is different from his birth country refers to birthCountry! = deathCountry
SELECT firstName, lastName FROM Master WHERE birthCountry != deathCountry ORDER BY birthYear
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 ...
movie_3
Calculate the average rate of renting the film that Lucille Tracy got starred.
average rate = divide(sum(rental_rate), count(film_id))
SELECT AVG(T3.rental_rate) 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 T1.first_name = 'LUCILLE' AND T1.last_name = 'TRACY'
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...
donor
What is the sum of the total donated amounts paid through Amazon?
paid through Amazon refers to payment_method = 'Amazon'; sum of the total donated amounts refers to SUM(donation_to_project,donation_optional_support)
SELECT SUM(donation_to_project) + SUM(donation_optional_support) FROM donations WHERE payment_method = 'amazon'
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 ...
movie_3
State the name of the category which has the most number of films.
category refers to name; most number of films refers to Max(Count(film_id))
SELECT T.name FROM ( SELECT T2.name, COUNT(T1.film_id) AS num FROM film_category AS T1 INNER JOIN category AS T2 ON T1.category_id = T2.category_id GROUP BY T2.name ) AS T ORDER BY T.num 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...
sales
In sales with a quantity of 60, how many of them have a price not greater than 500?
SELECT COUNT(T1.ProductID) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T2.quantity = 60 AND T1.Price <= 500
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...
shipping
Calculate the difference between the number of shipments shipped by the truck with the model year 2005 and model year 2006.
"2005" and "2006" are both model_year of truck; difference = Subtract (Count (ship_id where model_year = 2005), Count(ship_id where model_year = 2006))
SELECT SUM(CASE WHEN T1.model_year = '2005' THEN 1 ELSE 0 END) - SUM(CASE WHEN T1.model_year = '2006' THEN 1 ELSE 0 END) FROM truck AS T1 INNER JOIN shipment AS T2 ON T1.truck_id = T2.truck_id
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...
works_cycles
How many products were on the LL Road Frame Sale?
LL Road Frame Sale is a description of special offer
SELECT COUNT(DISTINCT ProductID) FROM SpecialOffer AS T1 INNER JOIN SpecialOfferProduct AS T2 ON T1.SpecialOfferID = T2.SpecialOfferID WHERE T1.Description = 'LL Road Frame Sale'
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 ...
restaurant
How many Indian restaurants are there in the Los Angeles area?
Indian restaurant refers to food_type = 'indian'; the Los Angeles area refers to region = 'los angeles area'
SELECT COUNT(T1.city) FROM geographic AS T1 INNER JOIN generalinfo AS T2 ON T1.city = T2.city WHERE T2.food_type = 'indian' AND T1.region = 'los angeles area'
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...
language_corpus
State the word ID for "periodograma".
word ID refers to wid; periodograma refers to word = 'periodograma'
SELECT wid FROM words WHERE word = 'periodograma'
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...
retails
List the phone numbers of suppliers from Japan.
phone number refers to s_phone; Japan refers to n_name = 'JAPAN'
SELECT T1.s_phone FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey WHERE T2.n_name = 'JAPAN'
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`),...
student_loan
How many employed disabled students have zero absences?
employed students refers to disabled.name who are NOT in unemployed.name; zero absences refers to month = 0;
SELECT COUNT(T1.name) FROM longest_absense_from_school AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name INNER JOIN unemployed AS T3 ON T3.name = T2.name WHERE T1.month = 0
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...
social_media
Please list the texts of all the tweets posted by male users from Buenos Aires.
"Buenos Aires" is the City; male user refers to Gender = 'Male'
SELECT T1.text FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID INNER JOIN user AS T2 ON T2.UserID = T1.UserID INNER JOIN user AS T3 ON T1.UserID = T3.UserID WHERE T2.City = 'Buenos Aires' AND T3.Gender = 'Male'
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 ( ...
professional_basketball
Please list the last names and first names of all-star players who are higher than 75 inch.
higher than 75 inch refers to height > 75
SELECT DISTINCT T1.lastName, T1.firstName FROM players AS T1 INNER JOIN player_allstar AS T2 ON T1.playerID = T2.playerID WHERE T1.height > 75
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
Which season played the highest number of matches at M Chinnaswamy Stadium?
season refers to Season_Id; the highest number of matches refers to max(count(Season_Id)); M Chinnaswamy Stadium refers to Venue_Name = 'M Chinnaswamy Stadium'
SELECT T1.Season_Id FROM `Match` AS T1 INNER JOIN Venue AS T2 ON T1.Venue_Id = T2.Venue_Id WHERE T2.Venue_Name = 'M Chinnaswamy Stadium' GROUP BY T1.Season_Id ORDER BY COUNT(T1.Season_Id) 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...
chicago_crime
What is the exact location of the crimes that occurred in the Belmont Cragin community?
Belmont Cragin community refers to community_area_name = 'Belmont Cragin'; exact location refers to latitude, longitude
SELECT T2.latitude, T2.longitude FROM Community_Area AS T1 INNER JOIN Crime AS T2 ON T2.community_area_no = T1.community_area_no WHERE T1.community_area_name = 'Belmont Cragin' GROUP BY T2.latitude, T2.longitude
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 ...
retails
Among the parts that are returned, how many of them are provided by a supplier in debt?
returned refers to l_returnflag = 'R'; in debt refers to s_acctbal < 0
SELECT COUNT(T1.l_partkey) FROM lineitem AS T1 INNER JOIN supplier AS T2 ON T1.l_suppkey = T2.s_suppkey WHERE T1.l_returnflag = 'R' AND T2.s_acctbal < 0
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 average profit of all the products from the Clothing category?
average profit = DIVIDE(SUM(SUBTRACT(ListPrice, StandardCost))), (COUNT(ProductSubcategoryID))));
SELECT SUM(T1.ListPrice - T1.StandardCost) / COUNT(T1.ProductID) FROM Product AS T1 INNER JOIN ProductSubcategory AS T2 ON T1.ProductSubcategoryID = T2.ProductSubcategoryID INNER JOIN ProductCategory AS T3 ON T2.ProductCategoryID = T3.ProductCategoryID WHERE T3.Name = 'Clothing'
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 ...
retail_complains
What is the medium through which most complaints are registered in Florida?
medium refers to "Submitted via"; most complaints refers to MAX(Complaint ID); Florida refers to state = 'florida';
SELECT T3.`Submitted via` FROM callcenterlogs AS T1 INNER JOIN client AS T2 ON T1.`rand client` = T2.client_id INNER JOIN events AS T3 ON T1.`Complaint ID` = T3.`Complaint ID` WHERE T2.state = 'FL' GROUP BY T1.`Complaint ID` ORDER BY COUNT(T1.`Complaint ID`) DESC LIMIT 1
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...
mondial_geo
What province does the 4th most populous city in the United Kingdom belong to, and how many people live there?
SELECT T1.Province, T1.Population FROM city AS T1 INNER JOIN country AS T2 ON T1.Country = T2.Code WHERE T2.Name = 'United Kingdom' ORDER BY T1.Population DESC LIMIT 3, 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...
talkingdata
What is the age of the oldest active user that participated in the event held on 5/6/2016 at coordinates 121, 31?
oldest user refers to MAX(age); active user refers to is_active = 1; on 5/6/2016 refers to timestamp LIKE '2016-05-06%'; coordinates 121, 31 refers to longitude = 121 AND latitude = 31;
SELECT T3.age FROM app_events AS T1 INNER JOIN events_relevant AS T2 ON T1.event_id = T2.event_id INNER JOIN gender_age AS T3 ON T2.device_id = T3.device_id WHERE T1.is_active = 1 AND T2.longitude = 121 AND T2.latitude = 31 AND SUBSTR(T2.timestamp, 1, 10) = '2016-05-06' ORDER BY T3.age DESC LIMIT 1
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...
legislator
Compare the number of legislators who started the term in 1875 and 2005.
started the term in 1875 refers to start LIKE '1875%'; started the term in 2005 refers to start LIKE '2005%'
SELECT SUM(CASE WHEN `current-terms`.start LIKE '2005%' THEN 1 ELSE 0 END) - ( SELECT SUM(CASE WHEN start LIKE '1875%' THEN 1 ELSE 0 END) FROM `historical-terms` ) FROM `current-terms`
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 ...
chicago_crime
What is the short description of the crime committed the most by criminals in the least populated community?
short description refers to title; committed the most refers to max(fbi_code_no); the least populated community refers to min(population)
SELECT T3.title FROM Community_Area AS T1 INNER JOIN Crime AS T2 ON T1.community_area_no = T2.community_area_no INNER JOIN FBI_Code AS T3 ON T2.fbi_code_no = T3.fbi_code_no GROUP BY T3.title ORDER BY T1.population ASC, T3.fbi_code_no DESC LIMIT 1
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 ...
codebase_comments
How many solutions does the repository which has 1445 Forks contain?
solutions refers to Solution.Id; repository refers to Repository.Id;
SELECT COUNT(T2.RepoId) FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T1.Forks = 1445
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...
simpson_episodes
How many episodes have won the award for Outstanding Animated Program (Programming Under One Hour) with less than 100 votes? Calculate the percentage of episodes with less than 100 votes out of total episodes.
less than 100 votes refers to votes < 100; percentage refers to DIVIDE(COUNT(episode_id when votes < 100), COUNT(episode_id)) * 100%
SELECT SUM(CASE WHEN T2.votes < 100 THEN 1 ELSE 0 END) AS num , CAST(SUM(CASE WHEN T2.votes < 100 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM Award AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Episode AS T3 ON T1.episode_id = T3.episode_id WHERE T1.award = 'Outstanding Animated Program ...
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, ...
social_media
Tweets posted from which city has a higher number of average likes, Bangkok or Chiang Mai?
"Bangkok" and "Chiang Mai" are both City; average number of like = Divide (Sum(Likes), Count(TweetID))
SELECT SUM(CASE WHEN T2.City = 'Bangkok' THEN Likes ELSE NULL END) / COUNT(CASE WHEN T2.City = 'Bangkok' THEN 1 ELSE 0 END) AS bNum , SUM(CASE WHEN City = 'Chiang Mai' THEN Likes ELSE NULL END) / COUNT(CASE WHEN City = 'Chiang Mai' THEN TweetID ELSE NULL END) AS cNum FROM twitter AS T1 INNER JOIN location AS T2 ON T1.L...
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 ( ...
disney
Who directed the movie with the most voice actors?
who directed refers director;
SELECT T2.director, COUNT(DISTINCT T1.`voice-actor`) FROM `voice-actors` AS T1 INNER JOIN director AS T2 ON T1.movie = T2.name GROUP BY T2.director ORDER BY COUNT(DISTINCT T1.`voice-actor`) DESC LIMIT 1
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...
music_tracker
How many releases by the artist michael jackson are tagged "pop"?
tag = 'pop';
SELECT COUNT(T1.groupName) FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T2.tag = 'pop' AND T1.artist = 'michael jackson'
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...
movies_4
How many adventure movies are there that were released in 2000?
adventure movies refers to genre_name = 'Adventure'; released in 2000 refers to release_date LIKE '2000%'
SELECT COUNT(T1.movie_id) FROM movie AS T1 INNER JOIN movie_genres AS T2 ON T1.movie_id = T2.movie_id INNER JOIN genre AS T3 ON T2.genre_id = T3.genre_id WHERE T3.genre_name = 'Adventure' AND CAST(STRFTIME('%Y', T1.release_date) AS INT) = 2000
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 ( ...
food_inspection_2
Which establishments did Joshua Rosa inspect?
establishment name refers to dba_name
SELECT DISTINCT T3.dba_name FROM employee AS T1 INNER JOIN inspection AS T2 ON T1.employee_id = T2.employee_id INNER JOIN establishment AS T3 ON T2.license_no = T3.license_no WHERE T1.first_name = 'Joshua' AND T1.last_name = 'Rosa'
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...
world
How many cities are there in the country ruled by Kostis Stefanopoulos?
ruled by Kostis Stefanopoulos refers to HeadOfState = 'Kostis Stefanopoulos';
SELECT COUNT(DISTINCT T1.Name) FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T2.HeadOfState = 'Kostis Stefanopoulos'
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...
video_games
What is the genre of the game '2 Games in 1: Sonic Advance & ChuChu Rocket!'?
genre refers to genre_name; '2 Games in 1: Sonic Advance & ChuChu Rocket!' is a game name;
SELECT T2.genre_name FROM game AS T1 INNER JOIN genre AS T2 ON T1.genre_id = T2.id WHERE T1.game_name = '2 Games in 1: Sonic Advance & ChuChu Rocket!'
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...
mental_health_survey
How many questions did user No.5 answer?
user No.5 refers to userID = 5
SELECT COUNT(QuestionID) FROM Answer WHERE UserID = 5
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...
olympics
What is the percentage of champions at the age of over 30?
DIVIDE(COUNT(competitor_id where age > 30), COUNT(competitor_id))as percentage where medal_id = 1;
SELECT CAST(COUNT(CASE WHEN T2.age > 30 THEN 1 END) AS REAL) * 100 / COUNT(T2.person_id) FROM competitor_event AS T1 INNER JOIN games_competitor AS T2 ON T1.competitor_id = T2.id WHERE T1.medal_id = 1
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...
social_media
What is the percentage of the tweets from California are positive?
"California" is the State; positive tweet refers to Sentiment > 0; percentage = Divide (Count(TweetID where Sentiment > 0), Count (TweetID)) * 100
SELECT SUM(CASE WHEN T1.Sentiment > 0 THEN 1.0 ELSE 0 END) / COUNT(T1.TweetID) AS percentage FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID WHERE State = 'California'
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 ( ...
hockey
Among the coaches who have received an award in 1940, how many of them are born in Toronto?
born in Toronto refers to birthCountry = 'Toronto'
SELECT COUNT(T1.coachID) FROM Master AS T1 INNER JOIN AwardsCoaches AS T2 ON T1.coachID = T2.coachID WHERE T2.year = 1940 AND T1.birthCity = 'Toronto'
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 ...
talkingdata
Give the number of 30-year-old users who were active in the events on 2016/5/2.
30-year-old refers to age = '30'; active refers to is_active = 1; on 2016/5/2 refers to timestamp = '2016/5/2 XX:XX:XX';
SELECT COUNT(T3.device_id) FROM app_events AS T1 INNER JOIN events AS T2 ON T1.event_id = T2.event_id INNER JOIN gender_age AS T3 ON T2.device_id = T3.device_id WHERE SUBSTR(`timestamp`, 1, 10) = '2016-05-02' AND T1.is_active = 1 AND T3.age = '30'
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...
regional_sales
How many sales teams are there in the Midwest?
"Midwest" is the Region
SELECT SUM(CASE WHEN Region = 'Midwest' THEN 1 ELSE 0 END) FROM `Sales Team`
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 ...
world_development_indicators
List down the top 3 Latin American & Caribbean countries with the highest average value in "CO2 emissions (kt)" indicator since 1965. Give their highest value and in what year.
Latin American & Caribbean countries is the name of the region where Region in ('Latin America' , 'Caribbean'); CO2 emissions from gaseous fuel consumption (kt) is the name of indicator where IndicatorName = 'CO2 emissions from gaseous fuel consumption (kt)'; average value in CO2 emissions (kt) = DIVIDE(SUM(Value), SUM...
SELECT DISTINCT T1.CountryCode, T1.Year, T1.Value FROM Indicators AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.CountryCode WHERE T2.Region = 'Latin America & Caribbean' AND T1.IndicatorName = 'CO2 emissions (kt)' AND T1.Year > 1965 AND T1.Year < 1980 ORDER BY T1.Value DESC LIMIT 3
CREATE TABLE IF NOT EXISTS "Country" ( CountryCode TEXT not null primary key, ShortName TEXT, TableName TEXT, LongName TEXT, Alpha2Code ...
works_cycles
What is the first name of the male employee who has a western name style?
western name style refers to NameStyle = 0; Male refers to Gender = 'M';
SELECT T2.FirstName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.NameStyle = 0 AND T1.Gender = 'M'
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 ...
works_cycles
What is the credit rating of the company whose average lead time is 16 days for a standard price of 18.9900 and whose last receipt date is August 27, 2011?
last receipt date is August 17, 2011 refers to LastReceiptDate> = '2011-08-17 00:00:00' and LastReceiptDate < '2011-08-18 00:00:00';
SELECT T2.CreditRating FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.StandardPrice = 18.9900 AND T1.AverageLeadTime = 16 AND STRFTIME('%Y-%m-%d', T1.LastReceiptDate) = '2011-08-27'
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 organizations are established in countries where people speak Bosnian?
Bosnian is one of language
SELECT COUNT(T2.Name) FROM language AS T1 INNER JOIN organization AS T2 ON T1.Country = T2.Country WHERE T1.Name = 'Bosnian'
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...
retails
How many in debt customers in the household market segment are from Russia?
in debt customers refer to c_custkey where c_acctbal < 0; c_mktsegment = 'HOUSEHOLD'; Russian is the name of the nation which refers to n_name = 'RUSSIA';
SELECT COUNT(T1.c_custkey) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T1.c_acctbal < 0 AND T1.c_mktsegment = 'HOUSEHOLD' AND T2.n_name = 'RUSSIA'
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`),...
public_review_platform
Please indicate the opening day of businesses whose category is pets.
category is pets refers to category_name = 'Pets'; opening day refers to day_id from Business_Hours and opening_time;
SELECT DISTINCT T4.day_of_week FROM Business_Categories AS T1 INNER JOIN Categories AS T2 ON T1.category_id = T2.category_id INNER JOIN Business_Hours AS T3 ON T1.business_id = T3.business_id INNER JOIN Days AS T4 ON T3.day_id = T4.day_id WHERE T2.category_name = 'Pets'
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 ...
world
Which country has the most crowded city in the world?
most crowded city refers to MAX(Population);
SELECT T1.Name FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode ORDER BY T2.Population DESC 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...
movie_platform
How many movies did the director of the highest movie popularity make?
highest movie popularity refers to MAX(movie_popularity)
SELECT COUNT(movie_id) FROM movies WHERE director_id = ( SELECT director_id FROM movies ORDER BY movie_popularity 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...
student_loan
State name of students who have the longest duration of absense from school and do not have payment due.
longest duration of absence from school refers to MAX(month); do not have payment due refers to bool = 'neg';
SELECT T1.name FROM longest_absense_from_school AS T1 INNER JOIN no_payment_due AS T2 ON T1.name = T2.name WHERE T2.bool = 'neg' ORDER BY T1.month DESC LIMIT 1
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...
simpson_episodes
List the nominee, keywords and episode ID of the title "The Good, the Sad and the Drugly".
nominee refers to result = 'Nominee'
SELECT T3.person, T1.keyword, T1.episode_id FROM Keyword AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Award AS T3 ON T2.episode_id = T3.episode_id WHERE T2.title = 'The Good, the Sad and the Drugly' AND T3.result = 'Nominee';
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, ...
movie_3
How many different clients have rented materials from Jon Stephens?
'Jon Stephens' is a full name of a customer; full name refers to first_name, last_name;
SELECT COUNT(T1.customer_id) FROM rental AS T1 INNER JOIN staff AS T2 ON T1.staff_id = T2.staff_id WHERE T2.first_name = 'Jon' AND T2.last_name = 'Stephens'
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...
movies_4
Look for the movie title with the keyword of "angel".
keyword of "angel" refers to keyword_name = 'angel'
SELECT T1.title FROM movie AS T1 INNER JOIN movie_keywords AS T2 ON T1.movie_id = T2.movie_id INNER JOIN keyword AS T3 ON T2.keyword_id = T3.keyword_id WHERE T3.keyword_name = 'angel'
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 ( ...
student_loan
How many disabled students have been absent for 3 months from school?
have been absent for 3 months from school refers to month = 3
SELECT COUNT(T1.name) FROM longest_absense_from_school AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name WHERE T1.month = 3
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...
student_loan
State name of unemployed students who have the longest duration of absense from school.
longest duration of absense refers to MAX(month)
SELECT T1.name FROM longest_absense_from_school AS T1 INNER JOIN unemployed AS T2 ON T1.name = T2.name ORDER BY T1.month DESC LIMIT 1
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...
retails
Provide the phone number of the customer with the highest total price in an order.
phone number of the customer refers to c_phone; the highest total price refers to MAX(o_totalprice);
SELECT T2.c_phone FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey ORDER BY T1.o_totalprice DESC LIMIT 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`),...
works_cycles
How many letters are there in Catherine Ward's e-mail account passwords?
Catherine Ward refers to the name of BusinessEntityID; how many letters in password for the e-mail account refers to LENGTH(PasswordHash)
SELECT LENGTH(T2.PasswordHash) FROM Person AS T1 INNER JOIN Password AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.FirstName = 'Catherine' AND T1.LastName = 'Ward'
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 ...
car_retails
How many checks were issued by Euro+ Shopping Channel in the year 2004?
Euro+ Shopping Channel is a customer name; year(paymentDate) = '2004';
SELECT COUNT(T1.checkNumber) FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE customerName = 'Euro+ Shopping Channel' AND STRFTIME('%Y', T1.paymentDate) = '2004'
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...
address
Provide the zip codes and coordinates of the postal points under Allentown-Bethlehem-Easton, PA-NJ.
coordinates refer to latitude and longitude; under Allentown-Bethlehem-Easton, PA-NJ refers to CBSA_name = 'Allentown-Bethlehem-Easton, PA-NJ';
SELECT T2.zip_code, T2.latitude, T2.longitude FROM CBSA AS T1 INNER JOIN zip_data AS T2 ON T1.CBSA = T2.CBSA WHERE T1.CBSA_name = 'Allentown-Bethlehem-Easton, PA-NJ'
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 ...
retail_world
How many boxes of 'Pavlova' did Northwind sell?
'Pavlova' is a ProductName
SELECT COUNT(T2.Quantity) FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductName = 'Pavlova'
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, ...
olympics
Which city were the Olympic games held in 1992?
city refers to city_name; in 1992 refers to games_year = 1992;
SELECT T2.city_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 T3.games_year = 1992
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...
shakespeare
List the chapter ID of the works with a year greater than the 89% of average year of all listed works of Shakespeare.
a year greater than the 89% of average year refers to DATE > multiply(divide(SUM(DATE) , COUNT(DATE)), 0.89)
SELECT T2.id FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id WHERE T1.DATE > ( SELECT AVG(DATE) FROM works ) * 0.89
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...
superstore
Among the products under the office supplies category, what is the product that made the highest sales in the Central region?
made the highest sales refers to MAX(Sales)
SELECT T2.`Product Name` FROM central_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T2.Category = 'Office Supplies' AND T2.Region = 'Central' ORDER BY T1.Sales DESC LIMIT 1
CREATE TABLE people ( "Customer ID" TEXT, "Customer Name" TEXT, Segment TEXT, Country TEXT, City TEXT, State TEXT, "Postal Code" INTEGER, Region TEXT, primary key ("Customer ID", Region) ); CREATE TABLE product ( "Product ID" TE...
professional_basketball
in which year costela01 obtained the best balance of games won as a coach?
"costela01" is the coachID; best balance of game won refers to Max(Divide(won, Sum(won, lost)))
SELECT year FROM coaches WHERE coachID = 'costela01' ORDER BY CAST(won AS REAL) / (won + lost) 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...
hockey
For the goalie who had the highest defensive success rate in the postseason of 2011, what's his legends ID ?
Post season of 2011 refers to year = ’2011’ defensive success rate refers to (SUBTRACT(1 (DIVIDE(PostGA/PostSA)), *100%)
SELECT T2.legendsID FROM Goalies AS T1 INNER JOIN Master AS T2 ON T1.playerID = T2.playerID WHERE T1.year = 2011 ORDER BY 1 - CAST(T1.PostGA AS REAL) / T1.PostSA DESC LIMIT 1
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
On image no. 20, identify the attribute ID that is composed of the highest number of objects.
image no. 20 refers to IMG_ID = 20; attribute ID refers to ATT_CLASS_ID; highest number of objects refers to max(count(ATT_CLASS_ID))
SELECT ATT_CLASS_ID FROM IMG_OBJ_ATT WHERE IMG_ID = 20 GROUP BY ATT_CLASS_ID ORDER BY COUNT(ATT_CLASS_ID) DESC LIMIT 1
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 country has the 5th highest infant mortality rate?
SELECT T2.Name FROM population AS T1 INNER JOIN country AS T2 ON T1.Country = T2.Code ORDER BY T1.Infant_Mortality DESC LIMIT 4, 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...
world_development_indicators
From 1975 to 1980, how much is the total amount CO2 emmission in kiloton of the the world? Indicate which year the world recorded its highest CO2 emmissions.
from 1975 to 1980 refers to Year between 1975 and 1980; the total amount CO2 emmission in kiloton of the the world refers to sum(value where IndicatorName like 'CO2%'); the world recorded its highest CO2 emmissions refers to max(value where IndicatorName like 'CO2%')
SELECT SUM(T1.Value), T1.Year FROM Indicators AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.CountryCode WHERE T1.IndicatorName = 'CO2 emissions (kt)' AND T1.Year >= 1975 AND T1.Year < 1981 AND T1.CountryCode = 'WLD' AND T2.SpecialNotes = 'World aggregate.'
CREATE TABLE IF NOT EXISTS "Country" ( CountryCode TEXT not null primary key, ShortName TEXT, TableName TEXT, LongName TEXT, Alpha2Code ...