db_id stringlengths 4 28 | question stringlengths 24 325 | evidence stringlengths 0 673 | SQL stringlengths 23 804 | schema stringlengths 352 37.3k |
|---|---|---|---|---|
works_cycles | How many black-colored products are there that cannot be sold? | cannot be sold means product is not a salable item which refers to FinishedGoodsFlag = 0 | SELECT COUNT(ProductID) FROM Product WHERE FinishedGoodsFlag = 0 AND Color = 'Black' | 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
... |
language_corpus | How many times does the word "riu" appears in the biwords pair? | riu refers to word = 'riu'; SUM(w1st where wid is word = 'riu' AND w2nd where wid is word = 'riu') | SELECT COUNT(T1.wid) 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 = 'riu' | 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... |
car_retails | What is the percentage of the payment amount in 2004 was made by Atelier graphique? | DIVIDE(SUM(amount) where customerName = 'Atelier graphique'), (SUM(amount)) as percentage where year(paymentDate) = 2004; | SELECT SUM(CASE WHEN t1.customerName = 'Atelier graphique' THEN t2.amount ELSE 0 END) * 100 / SUM(t2.amount) FROM customers AS t1 INNER JOIN payments AS t2 ON t1.customerNumber = t2.customerNumber WHERE STRFTIME('%Y', t2.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... |
movie_3 | How many times is the number of films Gina DeGeneres acted in than Penelope Guinness? | "Gina DeGeneres" and "Penelope Guinness" are both full name of actor; times number of film = Divide (Count (film_id where first_name = 'GINA' and last_name = 'DEGENERES'), Count(film_id where first_name = 'PENELOPE' and last_name = 'GUINESS')) | SELECT CAST(SUM(IIF(T2.first_name = 'GINA' AND T2.last_name = 'DEGENERES', 1, 0)) AS REAL) * 100 / SUM(IIF(T2.first_name = 'PENELOPE' AND T2.last_name = 'GUINESS', 1, 0)) FROM film_actor AS T1 INNER JOIN actor AS T2 ON T1.actor_id = T2.actor_id | 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... |
hockey | What is the total amount of assists of the NHL player with the most assists in history? Please indicate his/her full name. | NHL refers to lgID = 'NHL'; most assists refers to max(A); full name = nameGiven + lastName; total amount of assists = sum(A(playerID(max(A)))) | SELECT SUM(T1.A), T2.firstName, T2.lastName FROM Scoring AS T1 INNER JOIN Master AS T2 ON T1.playerID = T2.playerID WHERE T1.lgID = 'NHL' GROUP BY T2.firstName, T2.lastName ORDER BY SUM(T1.A) 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 ... |
sales | Identify the name of the sales person with employee ID 7. | name of the sales person = FirstName, MiddleInitial, LastName; | SELECT FirstName, MiddleInitial, LastName FROM Employees WHERE EmployeeID = 7 | 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... |
talkingdata | On which brand of phone are the most applications installed? | brand of phone refers to phone_brand; most applications are installed refers to MAX(COUNT(is_installed = 1)); | SELECT T.phone_brand FROM ( SELECT T1.phone_brand, COUNT(T4.is_active) AS num FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T1.device_id = T2.device_id INNER JOIN events_relevant AS T3 ON T2.device_id = T3.device_id INNER JOIN app_events_relevant AS T4 ON T3.event_id = T4.event_id WHERE T4.is_acti... | 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... |
car_retails | For the productline where the product No.S18_2949 was produced, what's the text description for that product line? | SELECT t1.textDescription FROM productlines AS t1 INNER JOIN products AS t2 ON t1.productLine = t2.productLine WHERE t2.productCode = 'S18_2949' | 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... | |
olympics | Among the males, list the region name of people with height greater than 87% of the average height of all people listed. | males refer to gender = 'M'; height greater than 87% of the average height refers to height > MULTIPLY(AVG(height), 0.87); | SELECT DISTINCT T1.region_name FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.gender = 'M' AND T3.height * 100 > ( SELECT AVG(height) FROM person WHERE gender = 'M' ) * 87 | 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... |
superstore | List the name of all products in the west superstore that customers chose for same-day shipment in the year 2013. | name of all products refers to Product Name; same-day shipment refers to "Ship Mode" = 'Same Day'; year 2013 refers to "Ship Date" BETWEEN '2013-01-01' AND '2013-12-31' | SELECT T2.`Product Name` FROM west_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T1.`Ship Mode` = 'Same Day' AND T1.`Ship Date` LIKE '2013%' | 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... |
chicago_crime | How many crime against society were reported in Englewood? | "Englewood" is the community_area_name; 'Society' is the crime_against | SELECT SUM(CASE WHEN T3.community_area_name = 'Englewood' THEN 1 ELSE 0 END) FROM FBI_Code AS T1 INNER JOIN Crime AS T2 ON T1.fbi_code_no = T2.fbi_code_no INNER JOIN Community_Area AS T3 ON T2.community_area_no = T3.community_area_no WHERE T1.crime_against = 'Society' | 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 ... |
public_review_platform | How many businesses are opened the same number of hours every day of the week? | how much time does this business open refers to SUBTRACT(closing_time, opening_time); every day of the week refers to day_id BETWEEN 1 AND 7 | SELECT COUNT(business_id) FROM Business_Hours WHERE opening_time = '8AM' AND closing_time = '6PM' | 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 ... |
car_retails | Of all the classic cars, with a product scale of 1:18, which product is the most ordered product by customers? | classic car is a product line; most ordered product refers to MAX(quantityOrdered); | SELECT T1.productName FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode WHERE T1.productScale = '1:18' AND T1.productLine = 'Classic Cars' GROUP BY T1.productName ORDER BY SUM(T2.quantityOrdered) DESC LIMIT 1 | 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... |
movielens | Among the films directed by directors who direct the best, how many of them have an average rating of over 3.5? | d_quality = 5 refers to direct the best, d_quality = 0 refers to direct the worst | SELECT COUNT(*) FROM ( SELECT DISTINCT T2.movieid FROM directors AS T1 INNER JOIN movies2directors AS T2 ON T1.directorid = T2.directorid INNER JOIN u2base AS T3 ON T2.movieid = T3.movieid WHERE T1.d_quality = 5 GROUP BY T2.movieid HAVING AVG(T3.rating) > 3.5 ) AS T1 | 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... |
mental_health_survey | How many respondents who participated in the survey in 2014 work remotely at least 50% of the time? | respondents' and 'users' are synonyms; work remotely at least 50% of the time refers to AnswerText(SurveyID = 2014& QuestionID = 93) = 'Yes' | SELECT COUNT(T1.AnswerText) FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T1.QuestionID = 93 AND T1.SurveyID = 2014 AND T1.AnswerText = 'Yes' | 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 | Please list different IDs of movies that are the newest and have gotten the lowest rating. | Year contains relative value, higer year value refers to newer date; Year = 4 refers to newest date, Year = 1 refer to oldest date; Lowest rating = 1 | SELECT DISTINCT T1.movieid FROM u2base AS T1 INNER JOIN movies AS T2 ON T1.movieid = T2.movieid WHERE T2.year = 4 AND T1.rating = 1 | 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... |
mondial_geo | Please list the names of the countries with an inflation rate that's 30% above the average. | Average inflation rate = [sum(inflation) / count(countries)]; 30% above average implies inflation > 1.3 average inflation rate | SELECT T1.Name FROM country AS T1 INNER JOIN economy AS T2 ON T1.Code = T2.Country GROUP BY T1.Name, T2.Inflation HAVING T2.Inflation > AVG(T2.Inflation) * 1.3 | 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... |
authors | What is the name of the co-authors of the paper titled 'Particle identification using the time-over-threshold method in the ATLAS Transition Radiation Tracker'? | paper titled 'Particle identification using the time-over-threshold method in the ATLAS Transition Radiation Tracker' refers to Title = 'Particle identification using the time-over-threshold method in the ATLAS Transition Radiation Tracker' | SELECT T1.Name FROM PaperAuthor AS T1 INNER JOIN Paper AS T2 ON T1.PaperId = T2.Id WHERE T2.Title = 'Particle identification using the time-over-threshold method in the ATLAS Transition Radiation Tracker' | 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... |
airline | Give the name of the airline to which tail number N202NN belongs to. | name of the airline refers to Description; tail number refers to TAIL_NUM; TAIL_NUM = 'N202NN'; | SELECT T2.Description FROM Airlines AS T1 INNER JOIN `Air Carriers` AS T2 ON T1.OP_CARRIER_AIRLINE_ID = T2.Code WHERE T1.TAIL_NUM = 'N202NN' GROUP BY T2.Description | 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 ... |
hockey | How much is the total goals for player with player ID aaltoan01 and how old is this person? | total goals refer to SUM(G); how old = SUBTRACT(YEAR(CURDATE, birthYear); | SELECT SUM(T2.G), STRFTIME('%Y', CURRENT_TIMESTAMP) - T1.birthyear FROM Master AS T1 INNER JOIN Scoring AS T2 ON T1.playerID = T2.playerID WHERE T1.playerID = 'aaltoan01' GROUP BY T1.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 ... |
olympics | Calculate the percentage of women who have participated in Equestrianism Mixed Three-Day Event, Individual. | DIVIDE(COUNT(person_id where gender = 'F), COUNT(person_id)) as percentage where event_name = 'Equestrianism Mixed Three-Day Event, Individual'; | SELECT CAST(COUNT(CASE WHEN T1.gender = 'F' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.id) FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id INNER JOIN competitor_event AS T3 ON T2.id = T3.competitor_id INNER JOIN event AS T4 ON T3.event_id = T4.id WHERE T4.event_name = 'Equestrianism Mix... | 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_world | Which customer have the biggest purchase in one order and where does this order being ship to? | biggest purchase refers to max(ProductID.Order_Details); ship to refers to ShipCountry | SELECT T1.CompanyName, T2.ShipCountry FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN `Order Details` AS T3 ON T2.OrderID = T3.OrderID GROUP BY T1.CompanyName, T2.ShipCountry ORDER BY COUNT(T3.ProductID) DESC LIMIT 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,
... |
music_platform_2 | Which titles have the content "love" but the category is art produced between 2018 and 2019. | content love refers to content = 'love'; 'arts' is the category; produced between 2018 and 2019 refers to year (created_at) BETWEEN 2018 and 2019 | SELECT DISTINCT T2.title FROM categories AS T1 INNER JOIN reviews AS T2 ON T2.podcast_id = T1.podcast_id WHERE (T2.created_at LIKE '2018-%' AND T1.category = 'arts' AND T2.content LIKE '%love%') OR (T2.created_at LIKE '2019-%' AND T1.category = 'arts' AND T2.content LIKE '%love%') | 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
... |
mondial_geo | What's the name of the second biggest desert? | SELECT Name FROM desert ORDER BY Area DESC LIMIT 1, 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... | |
simpson_episodes | Among episodes aired in 2009, which episode has received the worst response based on the rating. | aired in 2009 refers to year(air_date) = 2009; received the worst response based on the rating refers to MIN(rating) | SELECT episode_id FROM Episode WHERE air_date LIKE '2009%' ORDER BY rating LIMIT 1; | 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,
... |
codebase_comments | What is the task of method number 2? | task of the method refers to the second part of the Name after the "."; method number refers to Method_100k.Id; Method_100k.Id = 2; | SELECT SUBSTR(SUBSTR(Name, INSTR(Name, '.') + 1), 1, INSTR(SUBSTR(Name, INSTR(Name, '.') + 1), '.') - 1) task FROM Method WHERE Id = 2 | 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... |
retails | What is the biggest discount among all orders for the part "burnished seashell gainsboro navajo chocolate"? | the biggest discount refers to max(l_discount); part "burnished seashell gainsboro navajo chocolate" refers to p_name = 'burnished seashell gainsboro navajo chocolate' | SELECT MAX(T1.l_discount) FROM lineitem AS T1 INNER JOIN part AS T2 ON T1.l_partkey = T2.p_partkey WHERE T2.p_name = 'burnished seashell gainsboro navajo chocolate' | CREATE TABLE `customer` (
`c_custkey` INTEGER NOT NULL,
`c_mktsegment` TEXT DEFAULT NULL,
`c_nationkey` INTEGER DEFAULT NULL,
`c_name` TEXT DEFAULT NULL,
`c_address` TEXT DEFAULT NULL,
`c_phone` TEXT DEFAULT NULL,
`c_acctbal` REAL DEFAULT NULL,
`c_comment` TEXT DEFAULT NULL,
PRIMARY KEY (`c_custkey`),... |
retail_world | Please list all the territories in the Eastern Region. | territories refers to TerritoryDescription; Eastern Region refers to RegionDescription = 'Eastern'; | SELECT DISTINCT T1.TerritoryDescription FROM Territories AS T1 INNER JOIN Region AS T2 ON T1.RegionID = T2.RegionID WHERE T2.RegionDescription = 'Eastern' | 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,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.