db_id
stringclasses
66 values
question
stringlengths
24
325
evidence
stringlengths
1
673
gold_query
stringlengths
23
804
db_schema
stringclasses
66 values
world
Among the countries that use Italian as their language, what is the percentage of republic countries?
use Italian as their language refers to `Language` = 'Italian'; percentage = MULTIPLY(DIVIDE(SUM(`Language` = 'Italian' WHERE GovernmentForm = 'Republic'), COUNT(`Language` = 'Italian')), 100); use Italian as their language refers to `Language` = 'Italian'; republic countries refers to GovernmentForm = 'Republic';
SELECT CAST(SUM(CASE WHEN T2.GovernmentForm = 'Republic' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM CountryLanguage AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.Language = 'Italian'
CREATE TABLE Country ( `Name` TEXT NOT NULL DEFAULT '', -- `SurfaceArea` REAL NOT NULL DEFAULT 0.00, -- `Continent` TEXT NOT NULL DEFAULT 'Asia', -- Example Values: `North America`, `Asia`, `Africa`, `Europe`, `South America` | Value Statics: Total count 239 - Distinct count 7 - Null count 0 `Population` INT...
sales
What is the best selling colour for HL Mountain Frame, 42?
best selling colour refers to name of product with higher total sales; SUM(SalesID WHERE Name = 'HL Mountain Frame - Silver, 42') > SUM(Name = 'HL Mountain Frame - Black, 42') means Silver is the best selling colour, otherwise Black is the best seling colour;
SELECT IIF(SUM(IIF(T1.Name = 'HL Mountain Frame - Silver, 42', T2.SalesID, 0)) - SUM(IIF(T1.Name = 'HL Mountain Frame - Black, 42', T2.SalesID, 0)) > 0, 'Silver', 'Black') FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER no...
olympics
List out years that only have summer games.
years refer to games_year; only have summer games refer to games_year where COUNT(games_name) = 1 and season = 'Summer';
SELECT games_year FROM games WHERE season != 'Winter' GROUP BY games_year HAVING COUNT(season) = 1
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NUL...
public_review_platform
Which Yelp_Business in Arizona gets the most number of reviews?
Arizona refers to state = 'AZ'; gets the most number of reviews refers to max(count(Reviews.business_id))
SELECT T1.user_id FROM Reviews AS T1 INNER JOIN Business AS T2 ON T1.business_id = T2.business_id WHERE T2.state LIKE 'AZ' GROUP BY T1.user_id ORDER BY COUNT(T1.user_id) DESC LIMIT 1
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
book_publishing_company
Name the title and publisher for title ID BU 2075. Provide all the royalty percentage for all ranges.
name the publisher refers to pub_name
SELECT T1.title, T3.pub_name, T2.lorange, T2.hirange, T2.royalty FROM titles AS T1 INNER JOIN roysched AS T2 ON T1.title_id = T2.title_id INNER JOIN publishers AS T3 ON T1.pub_id = T3.pub_id WHERE T1.title_id = 'BU2075'
CREATE TABLE jobs ( max_lvl INTEGER not null, -- Example Values: `10`, `250`, `225`, `200`, `175` | Value Statics: Total count 14 - Distinct count 8 - Null count 0 job_desc TEXT not null, -- Example Values: `New Hire - Job not specified`, `Chief Executive Officer`, `Business Operations Manager`, `Chief Financial O...
food_inspection
Please list the names of all the restaurants that have met all requirements in one inspection.
met all requirements refers to inspections where score = 100;
SELECT DISTINCT T2.name FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.score = 100
CREATE TABLE violations ( `risk_category` TEXT NOT NULL, -- Example Values: `Moderate Risk`, `Low Risk`, `High Risk` | Value Statics: Total count 36050 - Distinct count 3 - Null count 0 `date` DATE NOT NULL, -- `violation_type_id` TEXT NOT NULL, -- FOREIGN KEY (`business_id`) REFERENCES `businesses` (`busine...
world
Among the cities with a population between 140000 and 150000, list the country that has life expectancy greater than 80% life expectancy of all countries.
life expectancy greater than 80% life expectancy of all countries refers to LifeExpectancy < (MULTIPLY(AVG(LifeExpectancy), 0.8));
SELECT T2.Name FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.Population BETWEEN 140000 AND 150000 GROUP BY T2.Name, LifeExpectancy HAVING LifeExpectancy < ( SELECT AVG(LifeExpectancy) FROM Country ) * 0.8
CREATE TABLE Country ( `Name` TEXT NOT NULL DEFAULT '', -- `SurfaceArea` REAL NOT NULL DEFAULT 0.00, -- `Continent` TEXT NOT NULL DEFAULT 'Asia', -- Example Values: `North America`, `Asia`, `Africa`, `Europe`, `South America` | Value Statics: Total count 239 - Distinct count 7 - Null count 0 `Population` INT...
olympics
Give the name of the tallest athlete from Sweden.
the tallest athlete refers to id where MAX(height); from Sweden refers to region_name = 'Sweden'; name refers to full_name;
SELECT T3.full_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 T1.region_name = 'Sweden' ORDER BY T3.height DESC LIMIT 1
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NUL...
public_review_platform
What is the total number of active business in AZ with a high review count?
active business refers to active = 'true'; 'AZ' is the state; high review count refers to review_count = 'High'
SELECT COUNT(business_id) FROM Business WHERE state LIKE 'AZ' AND review_count LIKE 'High' AND active LIKE 'True'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
book_publishing_company
Which employee has the lowest job level. State the first name, last name and when he /she was hired.
lowest job level refers to MIN(job_lvl)
SELECT fname, lname, hire_date FROM employee ORDER BY job_lvl LIMIT 1
CREATE TABLE jobs ( max_lvl INTEGER not null, -- Example Values: `10`, `250`, `225`, `200`, `175` | Value Statics: Total count 14 - Distinct count 8 - Null count 0 job_desc TEXT not null, -- Example Values: `New Hire - Job not specified`, `Chief Executive Officer`, `Business Operations Manager`, `Chief Financial O...
food_inspection
Among the inspections carried out in 2016, how many of them are routine?
inspections carried out in 2016 refer to YEAR(date) = 2016; routine inspections refer to type = 'Routine - Unscheduled';
SELECT COUNT(`date`) FROM inspections WHERE STRFTIME('%Y', `date`) = '2016' AND type = 'Routine - Unscheduled'
CREATE TABLE violations ( `risk_category` TEXT NOT NULL, -- Example Values: `Moderate Risk`, `Low Risk`, `High Risk` | Value Statics: Total count 36050 - Distinct count 3 - Null count 0 `date` DATE NOT NULL, -- `violation_type_id` TEXT NOT NULL, -- FOREIGN KEY (`business_id`) REFERENCES `businesses` (`busine...
world
In countries with constitutional monarchy, what is the percentage of cities located in the district of England?
constitutional monarchy refers to GovernmentForm = 'Constitutional Monarchy'; percentage = MULTIPLY(DIVIDE(SUM(GovernmentForm = 'Constitutional Monarchy' WHERE District = 'England'), COUNT(GovernmentForm = 'Constitutional Monarchy')), 100)
SELECT CAST(SUM(CASE WHEN T1.District = 'England' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T2.GovernmentForm = 'Constitutional Monarchy'
CREATE TABLE Country ( `Name` TEXT NOT NULL DEFAULT '', -- `SurfaceArea` REAL NOT NULL DEFAULT 0.00, -- `Continent` TEXT NOT NULL DEFAULT 'Asia', -- Example Values: `North America`, `Asia`, `Africa`, `Europe`, `South America` | Value Statics: Total count 239 - Distinct count 7 - Null count 0 `Population` INT...
sales
Write down the name of products whose sale quantity is more than 950.
quantity is more than 950 refers to Quantity > 950;
SELECT DISTINCT T1.Name FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Quantity > 950
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER no...
public_review_platform
What is the average business time for Yelp_Business no.1 on weekends?
Yelp_Business no.1 refers to business_id = 1; on weekends refers to day_of_week = 'Saturday' or day_of_week = 'Sunday'; average business time refers to DIVIDE(SUBTRACT(closing_time, opening_time), 2)
SELECT T1.closing_time + 12 - T1.opening_time AS "avg opening hours" FROM Business_Hours AS T1 INNER JOIN Days AS T2 ON T1.day_id = T2.day_id WHERE T1.business_id = 1 AND (T2.day_of_week = 'Sunday' OR T2.day_of_week = 'Sunday')
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
book_publishing_company
State the publisher name for publisher ID 877? Calculate its average year to date sales.
publisher id refers to pub_id; publisher name refers to pub_name; average year to date sales = AVG(ytd_sales)
SELECT T2.pub_name, AVG(T1.ytd_sales) FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.pub_id = '0877' GROUP BY T2.pub_name
CREATE TABLE jobs ( max_lvl INTEGER not null, -- Example Values: `10`, `250`, `225`, `200`, `175` | Value Statics: Total count 14 - Distinct count 8 - Null count 0 job_desc TEXT not null, -- Example Values: `New Hire - Job not specified`, `Chief Executive Officer`, `Business Operations Manager`, `Chief Financial O...
food_inspection
How many restaurants have met all requirements in the inspection?
met all requirements in the inspection refers to score = 100;
SELECT COUNT(score) FROM inspections WHERE score = 100
CREATE TABLE violations ( `risk_category` TEXT NOT NULL, -- Example Values: `Moderate Risk`, `Low Risk`, `High Risk` | Value Statics: Total count 36050 - Distinct count 3 - Null count 0 `date` DATE NOT NULL, -- `violation_type_id` TEXT NOT NULL, -- FOREIGN KEY (`business_id`) REFERENCES `businesses` (`busine...
world
Provide the language used in the country ruled by Pierre Buyoya.
ruled by Pierre Buyoya refers to HeadOfState = 'Pierre Buyoya';
SELECT T1.Language FROM CountryLanguage AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T2.HeadOfState = 'Pierre Buyoya'
CREATE TABLE Country ( `Name` TEXT NOT NULL DEFAULT '', -- `SurfaceArea` REAL NOT NULL DEFAULT 0.00, -- `Continent` TEXT NOT NULL DEFAULT 'Asia', -- Example Values: `North America`, `Asia`, `Africa`, `Europe`, `South America` | Value Statics: Total count 239 - Distinct count 7 - Null count 0 `Population` INT...
sales
What is the average number of customers per sales person?
average = DIVIDE(COUNT(CustomerID), COUNT(EmployeeID));
SELECT CAST(COUNT(T1.CustomerID) AS REAL) / COUNT(T3.EmployeeID) FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Employees AS T3 ON T2.SalesPersonID = T3.EmployeeID
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER no...
olympics
Show the name of the competitor id 90991.
name of the competitor refers to full_name;
SELECT T1.full_name FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id WHERE T2.id = 90991
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NUL...
public_review_platform
What is the review length of user 60776 to business with business ID 1?
"60776" is the user_id
SELECT review_length FROM Reviews WHERE user_id = 60776 AND business_id = 1
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
book_publishing_company
List all employees who are at the maximum level in their job designation.
maximum level in their job designation refers to job_lvl = MAX(max_lvl)
SELECT T1.fname, T1.lname FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T1.job_lvl = T2.max_lvl
CREATE TABLE jobs ( max_lvl INTEGER not null, -- Example Values: `10`, `250`, `225`, `200`, `175` | Value Statics: Total count 14 - Distinct count 8 - Null count 0 job_desc TEXT not null, -- Example Values: `New Hire - Job not specified`, `Chief Executive Officer`, `Business Operations Manager`, `Chief Financial O...
food_inspection
How many restaurants' owners are in California?
restaurants' owners in California refer to owner_state = 'CA';
SELECT COUNT(owner_state) FROM businesses WHERE owner_state = 'CA'
CREATE TABLE violations ( `risk_category` TEXT NOT NULL, -- Example Values: `Moderate Risk`, `Low Risk`, `High Risk` | Value Statics: Total count 36050 - Distinct count 3 - Null count 0 `date` DATE NOT NULL, -- `violation_type_id` TEXT NOT NULL, -- FOREIGN KEY (`business_id`) REFERENCES `businesses` (`busine...
world
What is the life expectancy of the people living in Calama city?
null
SELECT T2.LifeExpectancy FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.Name = 'Calama'
CREATE TABLE Country ( `Name` TEXT NOT NULL DEFAULT '', -- `SurfaceArea` REAL NOT NULL DEFAULT 0.00, -- `Continent` TEXT NOT NULL DEFAULT 'Asia', -- Example Values: `North America`, `Asia`, `Africa`, `Europe`, `South America` | Value Statics: Total count 239 - Distinct count 7 - Null count 0 `Population` INT...
book_publishing_company
Name the title with the highest price published by 'Binnet & Hardley'.
published by refers to pub_name
SELECT T1.title FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.pub_name = 'Binnet & Hardley' ORDER BY T1.price DESC LIMIT 1
CREATE TABLE jobs ( max_lvl INTEGER not null, -- Example Values: `10`, `250`, `225`, `200`, `175` | Value Statics: Total count 14 - Distinct count 8 - Null count 0 job_desc TEXT not null, -- Example Values: `New Hire - Job not specified`, `Chief Executive Officer`, `Business Operations Manager`, `Chief Financial O...
chicago_crime
Among all the incidents with no arrest made, what is the percentage of them having a generic description of "BATTERY" in the IUCR classification?
incident with no arrest made refers to arrest = 'FALSE'; general description refers to primary_description; "BATTERY" is the primary_description; percentage = Divide (Count(iucr_no where primary_description = 'BATTERY'), Count(iucr_no)) * 100
SELECT CAST(SUM(CASE WHEN T1.primary_description = 'BATTERY' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*)FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T1.iucr_no = T2.iucr_no WHERE T2.arrest = 'FALSE'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
world
List down the languages of countries with an independence year between 1980 to 1995.
independence year between 1980 to 1995 refers to IndepYear BETWEEN 1980 AND 1995;
SELECT T2.Name, T1.Language FROM CountryLanguage AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T2.IndepYear BETWEEN 1980 AND 1995
CREATE TABLE Country ( `Name` TEXT NOT NULL DEFAULT '', -- `SurfaceArea` REAL NOT NULL DEFAULT 0.00, -- `Continent` TEXT NOT NULL DEFAULT 'Asia', -- Example Values: `North America`, `Asia`, `Africa`, `Europe`, `South America` | Value Statics: Total count 239 - Distinct count 7 - Null count 0 `Population` INT...
sales
What is the total sales amount for Reflector?
total sales amount = SUM(MULTIPLY(Price, Quantity)); 'Reflector' is name of product;
SELECT SUM(T1.Price * T2.quantity) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'Reflector'
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER no...
olympics
How many different events are there of Modern Pentathlon?
Modern Pentathlon refers to sport_name = 'Modern Pentathlon';
SELECT COUNT(DISTINCT T2.event_name) FROM sport AS T1 INNER JOIN event AS T2 ON T1.id = T2.sport_id WHERE T1.sport_name = 'Modern Pentathlon'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NUL...
public_review_platform
How many stars on average does user no.3 give to Yelp_Business in Arizona?
user no.3 refers to user_id = 3; in Arizona refers to state = 'AZ'; stars on average = avg(review_stars(user_id = 3))
SELECT AVG(T2.review_stars) FROM Business AS T1 INNER JOIN Reviews AS T2 ON T1.business_id = T2.business_id WHERE T1.state LIKE 'AZ' AND T2.user_id = 3
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
book_publishing_company
Who are the employees working for publisher not located in USA? State the employee's name and publisher name.
not located at USA refers to country! = 'USA'
SELECT T1.fname, T1.lname, T2.pub_name FROM employee AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.country != 'USA'
CREATE TABLE jobs ( max_lvl INTEGER not null, -- Example Values: `10`, `250`, `225`, `200`, `175` | Value Statics: Total count 14 - Distinct count 8 - Null count 0 job_desc TEXT not null, -- Example Values: `New Hire - Job not specified`, `Chief Executive Officer`, `Business Operations Manager`, `Chief Financial O...
chicago_crime
What is the average number of incidents per month in 2018 in the ward with the most population?
in 2018 refers to date like '%2018%'; ward with most population refers to Max(Population); average number of incident per month refers to Divide(Count(ward_no), 12)
SELECT COUNT(T1.ward_no) / 12 AS average FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE T2.date LIKE '%2018%' AND T1.Population = ( SELECT MAX(T1.Population) FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE T2.date LIKE '%2018%' )
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
world
How many cities are there in the country with the surface area of 652090?
null
SELECT T2.Name, COUNT(T1.Name) FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T2.SurfaceArea = 652090 GROUP BY T2.Name
CREATE TABLE Country ( `Name` TEXT NOT NULL DEFAULT '', -- `SurfaceArea` REAL NOT NULL DEFAULT 0.00, -- `Continent` TEXT NOT NULL DEFAULT 'Asia', -- Example Values: `North America`, `Asia`, `Africa`, `Europe`, `South America` | Value Statics: Total count 239 - Distinct count 7 - Null count 0 `Population` INT...
olympics
Which game has Jessica Carolina Aguilera Aguilera participated in? Give the id of the game.
id of the game refers to games_id;
SELECT T2.games_id FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id WHERE T1.full_name = 'Jessica Carolina Aguilera Aguilera'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NUL...
disney
Among the movies directed by Wolfgang Reitherman, which one of them was the most popular?
directed by Wolfgang Reitherman refers to director = 'Wolfgang Reitherman'; the most popular movie refers to MAX(total_gross);
SELECT T2.movie_title FROM director AS T1 INNER JOIN movies_total_gross AS T2 ON T1.name = T2.movie_title WHERE T1.director = 'Wolfgang Reitherman' ORDER BY T2.total_gross DESC LIMIT 1
CREATE TABLE movies_total_gross ( MPAA_rating TEXT, -- Example Values: `G`, ``, `Not Rated`, `PG`, `R` | Value Statics: Total count 579 - Distinct count 6 - Null count 0 release_date TEXT, -- total_gross TEXT, -- foreign key (movie_title) references characters(movie_title), movie_title TEXT, -- genre TEX...
public_review_platform
In users yelping since 2010 to 2012, how many of them has an low fans?
user yelping since 2010 to 2012 refers to user_yelping_since_year > = '2010' AND user_yelping_since_year < '2013'; low fans refers to user_fans = 'Low'
SELECT COUNT(user_id) FROM Users WHERE user_yelping_since_year BETWEEN 2010 AND 2012 AND user_fans LIKE 'Low'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
book_publishing_company
In which year has the most hired employees?
most hired employees refers to MAX(count(emp_id))
SELECT STRFTIME('%Y', hire_date) FROM employee GROUP BY STRFTIME('%Y', hire_date) ORDER BY COUNT(emp_id) DESC LIMIT 1
CREATE TABLE jobs ( max_lvl INTEGER not null, -- Example Values: `10`, `250`, `225`, `200`, `175` | Value Statics: Total count 14 - Distinct count 8 - Null count 0 job_desc TEXT not null, -- Example Values: `New Hire - Job not specified`, `Chief Executive Officer`, `Business Operations Manager`, `Chief Financial O...
chicago_crime
Please list the blocks where all the incidents in the district commanded by Robert A. Rubio took place.
"Robert A. Rubio" is the commander
SELECT T2.block FROM District AS T1 INNER JOIN Crime AS T2 ON T1.district_no = T2.district_no WHERE T1.commander = 'Robert A. Rubio'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
world
What is the life expectancy of the countries that uses Japanese as their language?
uses Japanese as their language refers to `Language` = 'Japanese';
SELECT AVG(T2.LifeExpectancy) FROM CountryLanguage AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.Language = 'Japanese'
CREATE TABLE Country ( `Name` TEXT NOT NULL DEFAULT '', -- `SurfaceArea` REAL NOT NULL DEFAULT 0.00, -- `Continent` TEXT NOT NULL DEFAULT 'Asia', -- Example Values: `North America`, `Asia`, `Africa`, `Europe`, `South America` | Value Statics: Total count 239 - Distinct count 7 - Null count 0 `Population` INT...
sales
Calculate the total number of sales closed by Michel E. DeFrance?
null
SELECT COUNT(T1.SalesID) FROM Sales AS T1 INNER JOIN Employees AS T2 ON T1.SalesPersonID = T2.EmployeeID WHERE T2.FirstName = 'Michel' AND T2.MiddleInitial = 'e' AND T2.LastName = 'DeFrance'
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER no...
olympics
Where is competitor Estelle Nze Minko from?
Where competitor is from refers to region_name;
SELECT T1.region_name FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.full_name = 'Estelle Nze Minko'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NUL...
public_review_platform
List down the business ID with a star range from 2 to 3, located at Mesa.
star range from 2 to 3 refers to stars > = 2 AND stars < 4;  located at Mesa refers to city = 'Mesa'
SELECT business_id FROM Business WHERE city LIKE 'Mesa' AND stars BETWEEN 2 AND 3
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
book_publishing_company
Name the Chief Executive Officer and when he/she was hired.
Chief Financial Offer is a job description which refers to job_desc
SELECT T1.fname, T1.lname, T1.hire_date FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T2.job_desc = 'Chief Financial Officier'
CREATE TABLE jobs ( max_lvl INTEGER not null, -- Example Values: `10`, `250`, `225`, `200`, `175` | Value Statics: Total count 14 - Distinct count 8 - Null count 0 job_desc TEXT not null, -- Example Values: `New Hire - Job not specified`, `Chief Executive Officer`, `Business Operations Manager`, `Chief Financial O...
chicago_crime
Which district commander was responsible for more incidents in January, 2018, Robert A. Rubio or Glenn White?
in January 2018 refers to Substr(date, 1, 1) = '1' AND Substr(date, 5, 4) = '2018'; 'Robert A. Rubio' and 'Glenn White' are both commander; responsible for more incident refers to Max(count(ward_no))
SELECT T1.commander FROM District AS T1 INNER JOIN Crime AS T2 ON T1.district_no = T2.district_no WHERE T1.commander IN ('Robert A. Rubio', 'Glenn White') AND SUBSTR(T2.date, 1, 1) = '1' AND SUBSTR(T2.date, 5, 4) = '2018' GROUP BY T1.commander
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
world
List down the cities belongs to the country that has surface area greater than 7000000.
surface area greater than 7000000 refers to SurfaceArea > 7000000;
SELECT T2.Name, T1.Name FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T2.SurfaceArea > 7000000
CREATE TABLE Country ( `Name` TEXT NOT NULL DEFAULT '', -- `SurfaceArea` REAL NOT NULL DEFAULT 0.00, -- `Continent` TEXT NOT NULL DEFAULT 'Asia', -- Example Values: `North America`, `Asia`, `Africa`, `Europe`, `South America` | Value Statics: Total count 239 - Distinct count 7 - Null count 0 `Population` INT...
olympics
How many competitor ids does Martina Kohlov have?
null
SELECT COUNT(T2.id) FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id WHERE T1.full_name = 'Martina Kohlov'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NUL...
disney
How much is the total gross of the movie with a song titled "Little Wonders"?
song = 'Little Wonders'
SELECT T1.total_gross FROM movies_total_gross AS T1 INNER JOIN characters AS T2 ON T2.movie_title = T1.movie_title WHERE T2.song = 'Little Wonders'
CREATE TABLE movies_total_gross ( MPAA_rating TEXT, -- Example Values: `G`, ``, `Not Rated`, `PG`, `R` | Value Statics: Total count 579 - Distinct count 6 - Null count 0 release_date TEXT, -- total_gross TEXT, -- foreign key (movie_title) references characters(movie_title), movie_title TEXT, -- genre TEX...
public_review_platform
In businesses with a category of automotive, how many of them has an star rating below 3?
"Automotive" is the category of business; star rating below 3 refers to stars < 3
SELECT COUNT(T1.business_id) FROM Business AS T1 INNER JOIN Business_Categories ON T1.business_id = Business_Categories.business_id INNER JOIN Categories AS T3 ON Business_Categories.category_id = T3.category_id WHERE T3.category_name LIKE 'Automotive' AND T1.stars < 3
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
book_publishing_company
For each publisher, state the type of titles they published order by the publisher name.
publisher name refers to pub_name
SELECT DISTINCT T2.pub_name, T1.type FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id ORDER BY T2.pub_name
CREATE TABLE jobs ( max_lvl INTEGER not null, -- Example Values: `10`, `250`, `225`, `200`, `175` | Value Statics: Total count 14 - Distinct count 8 - Null count 0 job_desc TEXT not null, -- Example Values: `New Hire - Job not specified`, `Chief Executive Officer`, `Business Operations Manager`, `Chief Financial O...
chicago_crime
District commander Robert A. Rubio was responsible for how many incidents in January, 2018?
in January 2018 refers to Substr(date, 1, 1) = '1' AND Substr(date, 5, 4) = '2018'
SELECT SUM(CASE WHEN SUBSTR(T2.date, 5, 4) = '2018' THEN 1 ELSE 0 END) FROM District AS T1 INNER JOIN Crime AS T2 ON T1.district_no = T2.district_no WHERE T1.commander = 'Robert A. Rubio' AND SUBSTR(T2.date, 1, 1) = '1'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
world
What is the local name of the country where "The Valley" city belongs?
null
SELECT T2.LocalName FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.Name = 'The Valley'
CREATE TABLE Country ( `Name` TEXT NOT NULL DEFAULT '', -- `SurfaceArea` REAL NOT NULL DEFAULT 0.00, -- `Continent` TEXT NOT NULL DEFAULT 'Asia', -- Example Values: `North America`, `Asia`, `Africa`, `Europe`, `South America` | Value Statics: Total count 239 - Distinct count 7 - Null count 0 `Population` INT...
beer_factory
Give me the full name of the first customer, and tell me how long ago he or she wrote his or her first review since making his or her first purchase.
full name = First, Last; how long ago = SUBTRACT(ReviewDate, FirstPurchaseDate);
SELECT T1.First, T1.Last , strftime('%J', ReviewDate) - strftime('%J', FirstPurchaseDate) AS TIMEAGO FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID LIMIT 1
CREATE TABLE rootbeerbrand ( Website TEXT, -- State TEXT, -- Example Values: `CA`, `MA`, `LA`, `WA`, `QLD` | Value Statics: Total count 23 - Distinct count 14 - Null count 1 Twitter TEXT, -- Example Values: `https://twitter.com/ilovedads`, `https://twitter.com/1919rootbeer` | Value Statics: Total count 2 - Dist...
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 event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NUL...
disney
What is the Motion Picture Association of America rating for the movie featuring a villain named Turbo?
The Motion Picture Association of America rating refers to MPAA_rating; villian = 'Turbo';
SELECT T1.MPAA_rating FROM movies_total_gross AS T1 INNER JOIN characters AS T2 ON T2.movie_title = T1.movie_title WHERE T2.villian = 'Turbo'
CREATE TABLE movies_total_gross ( MPAA_rating TEXT, -- Example Values: `G`, ``, `Not Rated`, `PG`, `R` | Value Statics: Total count 579 - Distinct count 6 - Null count 0 release_date TEXT, -- total_gross TEXT, -- foreign key (movie_title) references characters(movie_title), movie_title TEXT, -- genre TEX...
chicago_crime
Among the incidents in January, 2018, how many of them were stated "against Property" in the FBI classification?
in January 2018 refers to Substr(date, 1, 1) = '1' AND Substr(date, 5, 4) = '2018'; against property refers to crime_against = 'Property'
SELECT SUM(CASE WHEN SUBSTR(T2.date, 5, 4) = '2018' THEN 1 ELSE 0 END) FROM FBI_Code AS T1 INNER JOIN Crime AS T2 ON T1.fbi_code_no = T2.fbi_code_no WHERE T1.crime_against = 'Property' AND SUBSTR(T2.date, 1, 1) = '1'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
world
What is the GNP of the country where district "Entre Rios" belongs?
null
SELECT T2.GNP FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.District = 'Entre Rios' LIMIT 1
CREATE TABLE Country ( `Name` TEXT NOT NULL DEFAULT '', -- `SurfaceArea` REAL NOT NULL DEFAULT 0.00, -- `Continent` TEXT NOT NULL DEFAULT 'Asia', -- Example Values: `North America`, `Asia`, `Africa`, `Europe`, `South America` | Value Statics: Total count 239 - Distinct count 7 - Null count 0 `Population` INT...
olympics
How many Olympic Games has London hosted?
London refers to city_name = 'London';
SELECT COUNT(T3.id) 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 = 'London'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NUL...
book_publishing_company
Name all the authors for all business titles.
business title refers to title under business where type = 'business'
SELECT T3.au_fname, T3.au_lname FROM titles AS T1 INNER JOIN titleauthor AS T2 ON T1.title_id = T2.title_id INNER JOIN authors AS T3 ON T2.au_id = T3.au_id WHERE T1.type = 'business'
CREATE TABLE jobs ( max_lvl INTEGER not null, -- Example Values: `10`, `250`, `225`, `200`, `175` | Value Statics: Total count 14 - Distinct count 8 - Null count 0 job_desc TEXT not null, -- Example Values: `New Hire - Job not specified`, `Chief Executive Officer`, `Business Operations Manager`, `Chief Financial O...
chicago_crime
Please list the case numbers of all the crimes whose short description of the kind of crime is "Homicide 1st & 2nd Degree" in the FBI classification.
"Homicide 1st & 2nd Degree" is the title
SELECT T2.case_number FROM FBI_Code AS T1 INNER JOIN Crime AS T2 ON T1.fbi_code_no = T2.fbi_code_no WHERE T1.title = 'Homicide 1st & 2nd Degree'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
world
List down the country names of countries that have a GNP lower than 1000 and have Dutch as their language.
GNP lower than 1000 refers to GNP < 1000; Dutch as their language refers to `Language` = 'Dutch';
SELECT T2.Name FROM CountryLanguage AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T2.GNP < 1000 AND T1.IsOfficial = 'T' AND T1.Language = 'Dutch'
CREATE TABLE Country ( `Name` TEXT NOT NULL DEFAULT '', -- `SurfaceArea` REAL NOT NULL DEFAULT 0.00, -- `Continent` TEXT NOT NULL DEFAULT 'Asia', -- Example Values: `North America`, `Asia`, `Africa`, `Europe`, `South America` | Value Statics: Total count 239 - Distinct count 7 - Null count 0 `Population` INT...
beer_factory
List down the brand names of root beer that gained a 5-star rating from a customer's review in 2013. Calculate the unit profit available to wholesalers for each brand.
5-star rating refers to StarRating = 5; in 2013 refers to ReviewDate LIKE '2013%'; unit profit available to wholesalers = SUBTRACT(CurrentRetailPrice, WholesaleCost);
SELECT T1.BrandName, T1.CurrentRetailPrice - T1.WholesaleCost AS result FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.StarRating = 5 AND T2.ReviewDate BETWEEN '2013-01-01' AND '2013-12-31'
CREATE TABLE rootbeerbrand ( Website TEXT, -- State TEXT, -- Example Values: `CA`, `MA`, `LA`, `WA`, `QLD` | Value Statics: Total count 23 - Distinct count 14 - Null count 1 Twitter TEXT, -- Example Values: `https://twitter.com/ilovedads`, `https://twitter.com/1919rootbeer` | Value Statics: Total count 2 - Dist...
olympics
How many persons participated in the Sapporo Olympics?
the Sapporo Olympics refer to games_id where city_name = 'Sapporo';
SELECT COUNT(T1.person_id) FROM games_competitor AS T1 INNER JOIN games_city AS T2 ON T1.games_id = T2.games_id INNER JOIN city AS T3 ON T2.city_id = T3.id WHERE T3.city_name = 'Sapporo'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NUL...
disney
In which segment did the Walt Disney Company earned a bigger revenue in 1998, Studio Entertainment or Disney Media Networks?
Studio Entertainment[NI 1]' > 'Disney Media Networks' where Year = 1998;
SELECT CASE WHEN 'Studio Entertainment[NI 1]' > 'Disney Media Networks' THEN 'Studio Entertainment[NI 1]' ELSE 'Disney Media Networks' END FROM revenue WHERE `Year` = 1998
CREATE TABLE movies_total_gross ( MPAA_rating TEXT, -- Example Values: `G`, ``, `Not Rated`, `PG`, `R` | Value Statics: Total count 579 - Distinct count 6 - Null count 0 release_date TEXT, -- total_gross TEXT, -- foreign key (movie_title) references characters(movie_title), movie_title TEXT, -- genre TEX...
public_review_platform
What is the average Elitestar rating for a Yelp_Business that closes at 12PM on Sundays?
average Elitestar rating refers to DIVIDE(SUM(stars), COUNT(business_id)); closes at 12PM refers to closing_time = '12PM'; on Sundays refers to day_of_week = 'Sunday'
SELECT CAST(SUM(T3.stars) AS REAL) / COUNT(T1.business_id) AS "average stars" FROM Business_Hours AS T1 INNER JOIN Days AS T2 ON T1.day_id = T2.day_id INNER JOIN Business AS T3 ON T1.business_id = T3.business_id WHERE T2.day_of_week LIKE 'Sunday' AND T1.closing_time LIKE '12PM'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
book_publishing_company
List all employees working for publisher 'GGG&G'. State their name and job description.
name = fname, lname; job description refers to job_desc; publisher refers pub_name
SELECT T1.fname, T1.lname, T3.job_desc FROM employee AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id INNER JOIN jobs AS T3 ON T1.job_id = T3.job_id WHERE T2.pub_name = 'GGG&G'
CREATE TABLE jobs ( max_lvl INTEGER not null, -- Example Values: `10`, `250`, `225`, `200`, `175` | Value Statics: Total count 14 - Distinct count 8 - Null count 0 job_desc TEXT not null, -- Example Values: `New Hire - Job not specified`, `Chief Executive Officer`, `Business Operations Manager`, `Chief Financial O...
chicago_crime
Among the incidents with the generic description of "BATTERY" in the IUCR classification, how many of them do not have arrests made?
general description refers to primary_description; 'BATTERY' is the primary_description; do not have arrest made refers to arrest = 'FALSE'
SELECT SUM(CASE WHEN T2.arrest = 'FALSE' THEN 1 ELSE 0 END) FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T1.iucr_no = T2.iucr_no WHERE T1.primary_description = 'BATTERY'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
world
What are the districts that belong to the country with the lowest surface area?
lowest surface area refers to MIN(SurfaceArea);
SELECT T1.District FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code ORDER BY T2.SurfaceArea ASC LIMIT 1
CREATE TABLE Country ( `Name` TEXT NOT NULL DEFAULT '', -- `SurfaceArea` REAL NOT NULL DEFAULT 0.00, -- `Continent` TEXT NOT NULL DEFAULT 'Asia', -- Example Values: `North America`, `Asia`, `Africa`, `Europe`, `South America` | Value Statics: Total count 239 - Distinct count 7 - Null count 0 `Population` INT...
sales
Name the sales person who helped Elizabeth A. White to purchase Road-250 Black, 48.
name of the sales person = FirstName, MiddleInitial, LastName; 'Road-250 Black, 48' is name of product;
SELECT DISTINCT T3.FirstName, T3.MiddleInitial, T3.LastName FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Employees AS T3 ON T2.SalesPersonID = T3.EmployeeID INNER JOIN Customers AS T4 ON T2.CustomerID = T4.CustomerID WHERE T4.MiddleInitial = 'A' AND T4.LastName = 'White' AND T1.N...
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER no...
olympics
How many athletes in the database are from Guatemala?
from Guatemala refers to region_name = 'Guatemala';
SELECT COUNT(T1.person_id) FROM person_region AS T1 INNER JOIN noc_region AS T2 ON T1.region_id = T2.id WHERE T2.region_name = 'Guatemala'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NUL...
public_review_platform
Among the businesses in Scottsdale, list the attribute of the business with a high review count.
"Scottsdale" is the name of city; high review count refers to review_count = 'High'; attribute of the business refers to attribute_name
SELECT T3.attribute_name FROM Business AS T1 INNER JOIN Business_Attributes AS T2 ON T1.business_id = T2.business_id INNER JOIN Attributes AS T3 ON T2.attribute_id = T3.attribute_id WHERE T1.review_count LIKE 'High' AND T1.city LIKE 'Scottsdale' GROUP BY T3.attribute_name
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
book_publishing_company
Among all employees, who have job level greater than 200. State the employee name and job description.
job level greater than 200 refers to job_lvl>200; job description refers to job_desc
SELECT T1.fname, T1.lname, T2.job_desc FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T1.job_lvl > 200
CREATE TABLE jobs ( max_lvl INTEGER not null, -- Example Values: `10`, `250`, `225`, `200`, `175` | Value Statics: Total count 14 - Distinct count 8 - Null count 0 job_desc TEXT not null, -- Example Values: `New Hire - Job not specified`, `Chief Executive Officer`, `Business Operations Manager`, `Chief Financial O...
chicago_crime
Please list the case numbers of all the incidents with the generic description of "BATTERY" in the IUCR classification.
general description refers to primary_description; 'BATTERY' is the primary_description
SELECT T2.case_number FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T1.iucr_no = T2.iucr_no WHERE T1.primary_description = 'BATTERY'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
world
List the names of the country that officially uses English as their language.
officially uses English as their language refers to `Language` = 'English' AND IsOfficial = 'T';
SELECT T2.Name FROM CountryLanguage AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.IsOfficial = 'T' AND T1.Language = 'English'
CREATE TABLE Country ( `Name` TEXT NOT NULL DEFAULT '', -- `SurfaceArea` REAL NOT NULL DEFAULT 0.00, -- `Continent` TEXT NOT NULL DEFAULT 'Asia', -- Example Values: `North America`, `Asia`, `Africa`, `Europe`, `South America` | Value Statics: Total count 239 - Distinct count 7 - Null count 0 `Population` INT...
sales
What is the difference in price between HL Mountain Frame - Black, 42 and LL Mountain Frame - Black, 42?
difference = SUBTRACT((Price WHERE Name = 'HL Mountain Frame - Black, 42'), (Price WHERE Name = 'HL Mountain Frame - Black, 42'));
SELECT ( SELECT Price FROM Products WHERE Name = 'HL Mountain Frame - Black, 42' ) - ( SELECT Price FROM Products WHERE Name = 'LL Mountain Frame - Black, 42' ) AS num
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER no...
disney
Among the movies directed by Wolfgang Reitherman, how many of them are Comedies?
directed by Wolfgang Reitherman refers to director = 'Wolfgang Reitherman'; comedies refers to genre = 'Comedy'; movies refer to movie_title;
SELECT COUNT(T3.name) FROM ( SELECT T2.name FROM `movies_total_gross` AS T1 INNER JOIN director AS T2 ON T1.movie_title = T2.name WHERE T2.director = 'Wolfgang Reitherman' AND T1.genre = 'Comedy' GROUP BY T2.name ) T3
CREATE TABLE movies_total_gross ( MPAA_rating TEXT, -- Example Values: `G`, ``, `Not Rated`, `PG`, `R` | Value Statics: Total count 579 - Distinct count 6 - Null count 0 release_date TEXT, -- total_gross TEXT, -- foreign key (movie_title) references characters(movie_title), movie_title TEXT, -- genre TEX...
book_publishing_company
For all authors from CA who are not on contract, which title of his/hers has the most year to date sales.
year to date sales refers to ytd_sales; on contract refers to contract = 1
SELECT T1.title FROM titles AS T1 INNER JOIN titleauthor AS T2 ON T1.title_id = T2.title_id INNER JOIN authors AS T3 ON T2.au_id = T3.au_id WHERE T3.contract = 0 AND T3.state = 'CA' ORDER BY T1.ytd_sales DESC LIMIT 1
CREATE TABLE jobs ( max_lvl INTEGER not null, -- Example Values: `10`, `250`, `225`, `200`, `175` | Value Statics: Total count 14 - Distinct count 8 - Null count 0 job_desc TEXT not null, -- Example Values: `New Hire - Job not specified`, `Chief Executive Officer`, `Business Operations Manager`, `Chief Financial O...
chicago_crime
The ward represented by which alderman had more incidents in January, 2018, Pat Dowell or Sophia King?
January, 2018 refers to Substr(date, 1, 1) = '1' AND Substr(date, 5, 4) = '2018'; had more incidents refers to Max(Count(ward_no))
SELECT T1.alderman_first_name, T1.alderman_last_name, COUNT(T1.ward_no) AS num FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE (SUBSTR(T2.date, 1, 1) = '1' AND SUBSTR(T2.date, 5, 4) = '2018' AND T1.alderman_first_name = 'Pat' AND T1.alderman_last_name = 'Dowell') OR (T1.alderman_first_name = 'So...
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
world
What is the surface area and GNP of the country where Namibe district belongs?
null
SELECT T2.SurfaceArea, T2.GNP FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.District = 'Namibe'
CREATE TABLE Country ( `Name` TEXT NOT NULL DEFAULT '', -- `SurfaceArea` REAL NOT NULL DEFAULT 0.00, -- `Continent` TEXT NOT NULL DEFAULT 'Asia', -- Example Values: `North America`, `Asia`, `Africa`, `Europe`, `South America` | Value Statics: Total count 239 - Distinct count 7 - Null count 0 `Population` INT...
disney
Who is the voice actor for the villain of the movie "Alice in Wonderland"?
Alice in Wonderland refers to movie_title = 'Alice in Wonderland'; villain refers to character like '%'||T1.villian||'%';
SELECT T1.`voice-actor` FROM `voice-actors` AS T1 INNER JOIN characters AS T2 ON T1.movie = T2.movie_title WHERE T1.character LIKE '%' OR T2.villian OR '%' AND T2.movie_title = 'Alice in Wonderland'
CREATE TABLE movies_total_gross ( MPAA_rating TEXT, -- Example Values: `G`, ``, `Not Rated`, `PG`, `R` | Value Statics: Total count 579 - Distinct count 6 - Null count 0 release_date TEXT, -- total_gross TEXT, -- foreign key (movie_title) references characters(movie_title), movie_title TEXT, -- genre TEX...
public_review_platform
What is the total number of active businesses in AZ with a low review count?
active businesses refers to active = 'true'; in AZ refers to state = 'AZ'
SELECT COUNT(business_id) FROM Business WHERE state LIKE 'AZ' AND active LIKE 'True' AND review_count LIKE 'low'
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
book_publishing_company
Name the publisher which has the most titles published in 1991.
most title published refers to MAX(count(title_id); published in 1991 refers to YEAR(pubdate) = 1991
SELECT T2.pub_name FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE STRFTIME('%Y', T1.pubdate) = '1991' GROUP BY T1.pub_id, T2.pub_name ORDER BY COUNT(T1.title_id) DESC LIMIT 1
CREATE TABLE jobs ( max_lvl INTEGER not null, -- Example Values: `10`, `250`, `225`, `200`, `175` | Value Statics: Total count 14 - Distinct count 8 - Null count 0 job_desc TEXT not null, -- Example Values: `New Hire - Job not specified`, `Chief Executive Officer`, `Business Operations Manager`, `Chief Financial O...
chicago_crime
Please list the location coordinates of all the incidents that had happened in the ward represented by alderman Pat Dowell.
location coordinates refers to latitude, longitude
SELECT T2.latitude, T2.longitude FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE T1.alderman_first_name = 'Pat' AND T1.alderman_last_name = 'Dowell' AND T2.latitude IS NOT NULL AND T2.longitude IS NOT NULL
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
world
What are the official languages of the country where you can find the city with the least population?
official language refers to IsOfficial = 'T'; least population refers to MIN(Population);
SELECT T2.Language FROM City AS T1 INNER JOIN CountryLanguage AS T2 ON T1.CountryCode = T2.CountryCode WHERE T2.IsOfficial = 'T' ORDER BY T1.Population ASC LIMIT 1
CREATE TABLE Country ( `Name` TEXT NOT NULL DEFAULT '', -- `SurfaceArea` REAL NOT NULL DEFAULT 0.00, -- `Continent` TEXT NOT NULL DEFAULT 'Asia', -- Example Values: `North America`, `Asia`, `Africa`, `Europe`, `South America` | Value Statics: Total count 239 - Distinct count 7 - Null count 0 `Population` INT...
sales
Calculate the revenue produced through sales of HL Road Frame - Red, 56.
revenue = MULTIPLY(SUM(Quantity, Price)); 'HL Road Frame - Red, 56' is name of product;
SELECT SUM(T2.Quantity * T1.Price) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'HL Road Frame - Red, 56'
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER no...
disney
How much more total box office gross did the Walt Disney Company have in revenue in 1998 than in 1997?
SUBTRACT(SUM(Year = 1998), SUM(Year = 1997))
SELECT SUM(CASE WHEN `Year` = 1998 THEN Total ELSE 0 END) - SUM(CASE WHEN `Year` = 1997 THEN Total ELSE 0 END) FROM revenue
CREATE TABLE movies_total_gross ( MPAA_rating TEXT, -- Example Values: `G`, ``, `Not Rated`, `PG`, `R` | Value Statics: Total count 579 - Distinct count 6 - Null count 0 release_date TEXT, -- total_gross TEXT, -- foreign key (movie_title) references characters(movie_title), movie_title TEXT, -- genre TEX...
public_review_platform
What is the attribute of the business with highest star rating?
highest star rating Max(stars); attribute of business refers to attribute_name
SELECT T3.attribute_name FROM Business AS T1 INNER JOIN Business_Attributes AS T2 ON T1.business_id = T2.business_id INNER JOIN Attributes AS T3 ON T2.attribute_id = T3.attribute_id ORDER BY T1.stars DESC LIMIT 1
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
book_publishing_company
List all the titles and year to date sales by author who are not on contract.
year to date sales refers to ytd_sales; not on contract refers to contract = 0
SELECT T1.title_id, T1.ytd_sales FROM titles AS T1 INNER JOIN titleauthor AS T2 ON T1.title_id = T2.title_id INNER JOIN authors AS T3 ON T2.au_id = T3.au_id WHERE T3.contract = 0
CREATE TABLE jobs ( max_lvl INTEGER not null, -- Example Values: `10`, `250`, `225`, `200`, `175` | Value Statics: Total count 14 - Distinct count 8 - Null count 0 job_desc TEXT not null, -- Example Values: `New Hire - Job not specified`, `Chief Executive Officer`, `Business Operations Manager`, `Chief Financial O...
chicago_crime
Among the crimes in the ward with the most population, how many of them are cases of domestic violence?
most population refers to Max(Population); domestic violence refers to domestic = 'TRUE'
SELECT COUNT(T1.ward_no) AS num FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE T2.domestic = 'TRUE' ORDER BY T1.Population = ( SELECT Population FROM Ward ORDER BY Population DESC LIMIT 1 )
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
world
Give the population of the country where Queimados city belongs.
null
SELECT T2.Population FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.Name = 'Queimados'
CREATE TABLE Country ( `Name` TEXT NOT NULL DEFAULT '', -- `SurfaceArea` REAL NOT NULL DEFAULT 0.00, -- `Continent` TEXT NOT NULL DEFAULT 'Asia', -- Example Values: `North America`, `Asia`, `Africa`, `Europe`, `South America` | Value Statics: Total count 239 - Distinct count 7 - Null count 0 `Population` INT...
sales
Among all customers handled by Innes E. del Castillo, how many have purchased Short-Sleeve Classic Jersey, L?
Short-Sleeve Classic Jersey, L' is name of product;
SELECT COUNT(T2.CustomerID) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Employees AS T3 ON T2.SalesPersonID = T3.EmployeeID WHERE T3.FirstName = 'Innes' AND T3.LastName = 'del Castillo' AND T1.Name = 'Short-Sleeve Classic Jersey, L' AND T3.MiddleInitial = 'e'
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER no...
olympics
In which Olympic Games has Morten Aleksander Djupvik participated?
In which Olympic Games refer to games_year;
SELECT T1.games_name FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.full_name = 'Morten Aleksander Djupvik'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NUL...
disney
Among the movies in which Alan Tudyk is a voice actor, how many of them were released after 2012?
released after 2012 refers to (release_date, instr(release_date, '-') + 5) > 12;
SELECT COUNT(T2.movie) FROM characters AS T1 INNER JOIN `voice-actors` AS T2 ON T1.movie_title = T2.movie WHERE T2.`voice-actor` = 'Alan Tudyk' AND SUBSTR(release_date, INSTR(release_date, '-') + 5) > 12
CREATE TABLE movies_total_gross ( MPAA_rating TEXT, -- Example Values: `G`, ``, `Not Rated`, `PG`, `R` | Value Statics: Total count 579 - Distinct count 6 - Null count 0 release_date TEXT, -- total_gross TEXT, -- foreign key (movie_title) references characters(movie_title), movie_title TEXT, -- genre TEX...
public_review_platform
What is the review length of user 35026 to business with business ID 2?
user 35026 refers to user_id = 35026
SELECT review_length FROM Reviews WHERE user_id = 35026 AND business_id = 2
CREATE TABLE Attributes ( attribute_name TEXT, -- attribute_id INTEGER constraint Attributes_pk primary key, ); CREATE TABLE Elite ( year_id INTEGER constraint Elite_Years_year_id_fk references Years, -- Example Values: `2010`, `2011`, `2012`, `2013`, `2014` | Value Statics: Total count 16366 - Distinct count 10 ...
book_publishing_company
Calculate the percentage of the employees who are Editor or Designer?
Editor or Auditor are job description which refers to job_desc; percentage = DIVIDE(count(job_desc = 'Editor' or job_desc = 'Auditor'), count(emp_id))*100
SELECT CAST(SUM(CASE WHEN T2.job_desc IN ('Editor', 'Designer') THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.job_id) FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id
CREATE TABLE jobs ( max_lvl INTEGER not null, -- Example Values: `10`, `250`, `225`, `200`, `175` | Value Statics: Total count 14 - Distinct count 8 - Null count 0 job_desc TEXT not null, -- Example Values: `New Hire - Job not specified`, `Chief Executive Officer`, `Business Operations Manager`, `Chief Financial O...
chicago_crime
Which alderman represents the ward with the most number of crimes in January, 2018? Please give his or her full name.
in January 2018 refers to Substr(date, 1, 1) = '1' AND Substr(date, 5, 4) = '2018'; ward with the most number of crime refers to Max (Count(ward_no)); full name refers to alderman_first_name, alderman_last_name, alderman_name_suffix
SELECT T1.ward_no, T1.alderman_first_name, T1.alderman_last_name, T1.alderman_name_suffix FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE SUBSTR(T2.date, 1, 1) = '1' AND SUBSTR(T2.date, 5, 4) = '2018' GROUP BY T1.ward_no ORDER BY COUNT(T1.ward_no) DESC LIMIT 1
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
world
What are the official languages used in Greece?
official language refers to IsOfficial = 'T'; Greece is a name of country;
SELECT T1.Language FROM CountryLanguage AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.IsOfficial = 'T' AND T2.name = 'Greece'
CREATE TABLE Country ( `Name` TEXT NOT NULL DEFAULT '', -- `SurfaceArea` REAL NOT NULL DEFAULT 0.00, -- `Continent` TEXT NOT NULL DEFAULT 'Asia', -- Example Values: `North America`, `Asia`, `Africa`, `Europe`, `South America` | Value Statics: Total count 239 - Distinct count 7 - Null count 0 `Population` INT...
olympics
Show the name of the sport with the most events.
name of the sport with the most events refers to sport_name where MAX(COUNT(id));
SELECT T1.sport_name FROM sport AS T1 INNER JOIN event AS T2 ON T1.id = T2.sport_id GROUP BY T1.sport_name ORDER BY COUNT(T2.event_name) DESC LIMIT 1
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NUL...
disney
Which movie is the character Robin Hood in?
Robin Hood is the main character of the movie which refers to hero = 'Robin Hood'; movie refers to movie_title;
SELECT movie_title FROM characters WHERE hero = 'Robin Hood'
CREATE TABLE movies_total_gross ( MPAA_rating TEXT, -- Example Values: `G`, ``, `Not Rated`, `PG`, `R` | Value Statics: Total count 579 - Distinct count 6 - Null count 0 release_date TEXT, -- total_gross TEXT, -- foreign key (movie_title) references characters(movie_title), movie_title TEXT, -- genre TEX...
chicago_crime
Among the crimes with no arrest made, how many of them happened in the ward represented by alderman Pat Dowell?
no arrest has been made refers to arrest = 'FALSE'
SELECT SUM(CASE WHEN T1.alderman_last_name = 'Dowell' THEN 1 ELSE 0 END) FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE T2.arrest = 'FALSE' AND T1.alderman_first_name = 'Pat'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
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 Country ( `Name` TEXT NOT NULL DEFAULT '', -- `SurfaceArea` REAL NOT NULL DEFAULT 0.00, -- `Continent` TEXT NOT NULL DEFAULT 'Asia', -- Example Values: `North America`, `Asia`, `Africa`, `Europe`, `South America` | Value Statics: Total count 239 - Distinct count 7 - Null count 0 `Population` INT...
sales
Name the customers who received 'Touring Rim' as a free gift.
name of the customer = FirstName, MiddleInitial, LastName; 'Touring Rim' is name of product;
SELECT DISTINCT T1.FirstName, T1.MiddleInitial, T1.LastName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T3.Name = 'Touring Rim' AND T3.Price = 0
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER no...