db_id
stringclasses
66 values
question
stringlengths
24
325
evidence
stringlengths
1
673
gold_query
stringlengths
23
804
db_schema
stringclasses
66 values
retail_world
How many customers are there in Berlin, Germany?
"Berlin" is the City; 'Germany' is the Country
SELECT COUNT(City) FROM Customers WHERE Country = 'Germany' AND City = 'Berlin'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
synthea
When the allergy starts for Angelo Buckridge.
null
SELECT T2.START FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Adolfo' AND T1.last = 'Schmitt' AND T2.STOP IS NOT NULL
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
mondial_geo
What form of governance does the least prosperous nation in the world have?
Nation and country are synonyms; Form of governance was mentioned in politics.Government; Least prosperous means lowest GDP
SELECT T3.Government FROM country AS T1 INNER JOIN economy AS T2 ON T1.Code = T2.Country INNER JOIN politics AS T3 ON T3.Country = T2.Country WHERE T2.GDP IS NOT NULL ORDER BY T2.GDP ASC LIMIT 1
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
Who is the sales representative of the customer who has made the highest payment? Include the full name of employee and his/her supervisor.
highest payment refers to Max(Multiply(Quantity, UnitPrice, Subtract(1, Discount))); full name refers to FirstName, LastName; his/her supervisor refers to 'ReportsTo'
SELECT T4.LastName, T4.FirstName, T4.ReportsTo , T1.Quantity * T1.UnitPrice * (1 - T1.Discount) AS payment FROM `Order Details` AS T1 INNER JOIN Orders AS T2 ON T1.OrderID = T2.OrderID INNER JOIN Customers AS T3 ON T2.CustomerID = T3.CustomerID INNER JOIN Employees AS T4 ON T2.EmployeeID = T4.EmployeeID ORDER BY paymen...
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
superstore
From which city and state does the customer that bought the product with the highest sales?
highest sales refers to max(Sales)
SELECT T5.City, T5.State 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.`Customer ID` INNER JOIN people AS T5 ON T5.`Customer ID` = T4...
CREATE TABLE west_superstore ( Profit REAL, -- Region TEXT, -- Example Values: `West` | Value Statics: Total count 6406 - Distinct count 1 - Null count 0 "Product ID" TEXT, -- foreign key ("Product ID", Region) references product("Product ID",Region), "Order Date" DATE, -- foreign key ("Customer ID", Reg...
computer_student
In total, all the students in the 3rd year of their program are advised by how many professors?
3rd year of their program refers to yearsInProgram = 'Year_3'; professors refers to p_id_dummy
SELECT COUNT(DISTINCT T1.p_id_dummy) FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.yearsInProgram = 'Year_3'
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_d...
mondial_geo
Which Asian country gave its agricultural sector the largest share of its gross domestic product?
Gross domestic product = GDP; Largest share of GDP in agricultural sector was mentioned in economy.Agriculture
SELECT T2.Country FROM continent AS T1 INNER JOIN encompasses AS T2 ON T1.Name = T2.Continent INNER JOIN country AS T3 ON T2.Country = T3.Code INNER JOIN economy AS T4 ON T4.Country = T3.Code WHERE T1.Name = 'Asia' ORDER BY T4.Agriculture DESC LIMIT 1
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
What is the contact name and phone number of the customer who has made the most total payment on the order to date?
most total payment = Max(Multiply(Quantity, UnitPrice, Subtract(1, Discount)))
SELECT T1.ContactName, T1.Phone 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 T2.OrderID, T1.ContactName, T1.Phone ORDER BY SUM(T3.UnitPrice * T3.Quantity * (1 - T3.Discount)) DESC LIMIT 1
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
synthea
Count all of the living patients that had a stroke.
if deathdate is null, it means this patient is still alive or living; stroke refers to conditions where DESCRIPTION = 'Stroke';
SELECT COUNT(DISTINCT T2.patient) FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.description = 'Stroke' AND T2.deathdate IS NULL
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
mondial_geo
Which nation, with a population ranging from 60,000,000 to 99,000,000, has the greatest gross domestic product?
GDP refers to gross domestic product; Nation and country are synonyms
SELECT T1.Name, T2.GDP FROM country AS T1 INNER JOIN economy AS T2 ON T1.Code = T2.Country WHERE T1.Population BETWEEN 60000000 AND 90000000 ORDER BY T2.GDP DESC LIMIT 1
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
Which of the American customers have experienced a delay in the shipment and how long was the longest?
"American" refers to Country = 'USA'; longest delay in shipment refers to Max(Subtract(RequiredDate, ShippedDate)); customer refers to CustomerID
SELECT T1.CompanyName, TIMESTAMPDIFF(DAY, T2.ShippedDate, T2.RequiredDate) FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Country = 'USA' AND TIMESTAMPDIFF(DAY, T2.ShippedDate, T2.RequiredDate) < 0
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
mondial_geo
What is the maximal elevation of the summit of the shortest mountain that can be found in the island of Madagaskar? Indicate what type of mountain it is.
The elevation of the summit refers to height
SELECT T3.Height, T3.Type FROM island AS T1 INNER JOIN mountainOnIsland AS T2 ON T1.Name = T2.Island INNER JOIN mountain AS T3 ON T3.Name = T2.Mountain WHERE T1.Name = 'Madagaskar' ORDER BY T3.Height DESC LIMIT 1
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
How many territories are owned by Anne Dodsworth?
null
SELECT COUNT(T2.TerritoryID) FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.FirstName = 'Anne' AND T1.LastName = 'Dodsworth'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
superstore
Among the customers from Chicago, Illinois, what is the highest quantity of products bought in a single order?
from Chicago refers to City = 'Chicago'; Illinois refers to State = 'Illinois'; highest quantity refers to max(Quantity)
SELECT T1.Quantity 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.`Customer ID` INNER JOIN people AS T5 ON T5.`Customer ID` = T4.`Cust...
CREATE TABLE west_superstore ( Profit REAL, -- Region TEXT, -- Example Values: `West` | Value Statics: Total count 6406 - Distinct count 1 - Null count 0 "Product ID" TEXT, -- foreign key ("Product ID", Region) references product("Product ID",Region), "Order Date" DATE, -- foreign key ("Customer ID", Reg...
synthea
List down the first name of patients who received "Influenza seasonal injectable preservative free" immunization.
"Influenza seasonal injectable preservative free" immunization refers to immunizations where DESCRIPTION = 'Influenza seasonal injectable preservative free';
SELECT DISTINCT T1.first, T1.last FROM patients AS T1 INNER JOIN immunizations AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Influenza seasonal injectable preservative free'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
mondial_geo
Which Zaire region is home to the country's deepest lake's Name it and list its depth.
null
SELECT T3.Name, T1.Name, T1.Depth FROM lake AS T1 INNER JOIN located AS T2 ON T1.Name = T2.Lake INNER JOIN province AS T3 ON T3.Name = T2.Province INNER JOIN country AS T4 ON T4.Code = T3.Country WHERE T4.Name = 'Zaire'
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
What is the stock value of every condiments?
"Condiments" is the CategoryName; Stock value = MULTIPLY( UnitPrice, UnitInStock)
SELECT T1.UnitPrice * T1.UnitsInStock FROM Products AS T1 INNER JOIN Categories AS T2 ON T1.CategoryID = T2.CategoryID
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
professional_basketball
List the full name of players who are born outside USA.
full name refers to firstName, middleName, lastName; born outside USA refers to birthCountry ! = 'USA'
SELECT firstName, middleName, lastName FROM players WHERE birthCountry != 'USA'
CREATE TABLE players_teams ( PostGS INTEGER, -- PostdRebounds INTEGER, -- PostPF INTEGER, -- tmID TEXT, -- threeAttempted INTEGER, -- PostRebounds INTEGER, -- assists INTEGER, -- threeMade INTEGER, -- PostBlocks INTEGER, -- PostTurnovers INTEGER, -- GP INTEGER, -- lgID TEXT, -- Example...
superstore
What product was ordered in the Central region on April 26, 2018, and shipped by April 27, 2018?
on April 26, 2018 refers to "Order Date" = date('2018-04-26'); shipped by April 27, 2018 refers to "Ship Date" = date('2018-04-27');
SELECT T2.`Product Name` FROM central_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T1.`Order Date` = '2018-04-26' AND T1.`Ship Date` = '2018-04-27' AND T2.Region = 'Central'
CREATE TABLE west_superstore ( Profit REAL, -- Region TEXT, -- Example Values: `West` | Value Statics: Total count 6406 - Distinct count 1 - Null count 0 "Product ID" TEXT, -- foreign key ("Product ID", Region) references product("Product ID",Region), "Order Date" DATE, -- foreign key ("Customer ID", Reg...
synthea
What is the medicine prescribed for the patient with social security number 999-94-3751?
medicine prescribed refers to DESCRIPTION from medications; social security number 999-94-3751 refers to ssn = '999-94-3751';
SELECT T1.DESCRIPTION FROM medications AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.ssn = '999-94-3751'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
mondial_geo
What is the name of the country with the smallest population, and what is its gross domestic product?
GDP refers to gross domestic product
SELECT T1.Name, T2.GDP FROM country AS T1 INNER JOIN economy AS T2 ON T1.Code = T2.Country ORDER BY T1.Population ASC LIMIT 1
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
What is the re-order level of products that have an order quantity of 1?
order quantity of 1 refers to Quantity = 1
SELECT T1.ReorderLevel FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Quantity = 1
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
superstore
List down the customers that purchased the product named Xerox 23 in the South region.
product named Xerox 23 refers to "Product Name" = 'Xerox 23'; customers refers to "Customer Name"
SELECT DISTINCT T2.`Customer Name` FROM south_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` INNER JOIN product AS T3 ON T3.`Product ID` = T1.`Product ID` WHERE T1.Region = 'South' AND T3.`Product Name` = 'Xerox 23'
CREATE TABLE west_superstore ( Profit REAL, -- Region TEXT, -- Example Values: `West` | Value Statics: Total count 6406 - Distinct count 1 - Null count 0 "Product ID" TEXT, -- foreign key ("Product ID", Region) references product("Product ID",Region), "Order Date" DATE, -- foreign key ("Customer ID", Reg...
mondial_geo
When did the country whose capital is Nouakchott attained it's independence?
null
SELECT T2.Independence FROM country AS T1 INNER JOIN politics AS T2 ON T1.Code = T2.Country WHERE T1.Capital = 'Nouakchott'
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
Tally the customer ID of orders that were shipped to Brazil by Margaret Peacock from 3/31/97 to 12/10/97.
"Brazil" is the ShipCountry; from 3/31/97 to 12/10/97 refers to 1997-03-31 < ShippedDate < 1997-10-12
SELECT DISTINCT T2.CustomerID FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.LastName = 'Peacock' AND T1.FirstName = 'Margaret' AND T2.ShipCountry = 'Brazil' AND T2.ShippedDate BETWEEN '1997-03-31 00:00:00' AND '1997-12-10 23:59:59'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
professional_basketball
Which state has the most players selected as all stars?
state refers to birthState; the most players refers to max(count(playerID))
SELECT T1.birthState FROM players AS T1 INNER JOIN player_allstar AS T2 ON T1.playerID = T2.playerID GROUP BY T1.birthState ORDER BY COUNT(DISTINCT T1.playerID) DESC LIMIT 1
CREATE TABLE players_teams ( PostGS INTEGER, -- PostdRebounds INTEGER, -- PostPF INTEGER, -- tmID TEXT, -- threeAttempted INTEGER, -- PostRebounds INTEGER, -- assists INTEGER, -- threeMade INTEGER, -- PostBlocks INTEGER, -- PostTurnovers INTEGER, -- GP INTEGER, -- lgID TEXT, -- Example...
mondial_geo
What river has the 17th-longest length overall? Specify it's length.
null
SELECT Name, Length FROM river ORDER BY Length DESC LIMIT 16, 1
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
From 1/3/97 to 8/10/97, how many orders were shipped via Federal Shipping?
from 1/3/97 to 8/10/97 refers to 1997-03-01 < ShippedDate < 1997-10-08; 'Federal Shipping' is the CompanyName
SELECT COUNT(T1.OrderID) FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T2.CompanyName = 'Federal Shipping' AND T1.ShippedDate BETWEEN '1997-03-01 00:00:00' AND '1997-10-08 23:59:59'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
superstore
Who is the customer from the East region that purchased the order with the highest profit?
highest profit refers to MAX(profit); Region = 'East'
SELECT T2.`Customer Name` FROM east_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T1.Region = 'East' ORDER BY T1.Profit DESC LIMIT 1
CREATE TABLE west_superstore ( Profit REAL, -- Region TEXT, -- Example Values: `West` | Value Statics: Total count 6406 - Distinct count 1 - Null count 0 "Product ID" TEXT, -- foreign key ("Product ID", Region) references product("Product ID",Region), "Order Date" DATE, -- foreign key ("Customer ID", Reg...
synthea
What kind of allergy is most common among white people?
kind of allergy is most common refers to MAX(COUNT(DESCRIPTION)) from allergies; white refers to race = 'white';
SELECT T2.DESCRIPTION FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T1.race = 'white' GROUP BY T2.DESCRIPTION ORDER BY COUNT(T2.DESCRIPTION) DESC LIMIT 1
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
mondial_geo
Which country has the widest range of religious practices?
null
SELECT T1.Name FROM country AS T1 INNER JOIN religion AS T2 ON T1.Code = T2.Country GROUP BY T1.Name ORDER BY COUNT(DISTINCT T2.Name) DESC LIMIT 1
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
How many employees have territories in the Eastern region?
"Eastern" is the RegionDescription
SELECT COUNT(DISTINCT T1.FirstName) FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Territories AS T3 ON T2.TerritoryID = T3.TerritoryID INNER JOIN Region AS T4 ON T3.RegionID = T4.RegionID WHERE T4.RegionDescription = 'Eastern'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
superstore
Who is the customer from the West region that received the highest discount?
received the highest discount refers to MAX(discount); customer refers to "Customer Name"
SELECT T2.`Customer Name` FROM west_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T1.Region = 'West' ORDER BY T1.Discount DESC LIMIT 1
CREATE TABLE west_superstore ( Profit REAL, -- Region TEXT, -- Example Values: `West` | Value Statics: Total count 6406 - Distinct count 1 - Null count 0 "Product ID" TEXT, -- foreign key ("Product ID", Region) references product("Product ID",Region), "Order Date" DATE, -- foreign key ("Customer ID", Reg...
mondial_geo
Which country has the 5th highest infant mortality rate?
null
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 politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
Among the employees, give me the full names of those who have less than 4 territories.
less than 4 territories refers to EmployeeID where Count(TerritoryID) < 4
SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.EmployeeID < 4
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
professional_basketball
Name the team in which the coach won the title 'NBA Coach of the Year' in 2010.
team name refers to teams.name; won the title 'NBA Coach of the Year' refers to award = 'NBA Coach of the Year'; in 2010 refers to year = 2010
SELECT DISTINCT T1.tmID FROM coaches AS T1 INNER JOIN awards_coaches AS T2 ON T1.coachID = T2.coachID WHERE T2.year = 2010 AND T2.award = 'NBA Coach of the Year'
CREATE TABLE players_teams ( PostGS INTEGER, -- PostdRebounds INTEGER, -- PostPF INTEGER, -- tmID TEXT, -- threeAttempted INTEGER, -- PostRebounds INTEGER, -- assists INTEGER, -- threeMade INTEGER, -- PostBlocks INTEGER, -- PostTurnovers INTEGER, -- GP INTEGER, -- lgID TEXT, -- Example...
superstore
What are the order date and product name of the order ID CA-2011-137274 from the Central region?
null
SELECT T1.`Order Date`, T2.`Product Name` FROM central_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T1.`Order ID` = 'CA-2011-137274' AND T2.Region = 'Central'
CREATE TABLE west_superstore ( Profit REAL, -- Region TEXT, -- Example Values: `West` | Value Statics: Total count 6406 - Distinct count 1 - Null count 0 "Product ID" TEXT, -- foreign key ("Product ID", Region) references product("Product ID",Region), "Order Date" DATE, -- foreign key ("Customer ID", Reg...
mondial_geo
What is the name of the most recently founded organization in Saudi Arabia?
Saudi Arabia is a country
SELECT T1.Name FROM organization AS T1 INNER JOIN country AS T2 ON T1.Country = T2.Code WHERE T2.Name = 'Saudi Arabia' ORDER BY T1.Established DESC LIMIT 1
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
Who are the suppliers of the discontinued products?
discontinued product refers to Discontinued = 1; supplier refers to CompanyName
SELECT DISTINCT T2.CompanyName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.Discontinued = 1
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
professional_basketball
In 1950, how many players whose teams have the losing rate less than 20%?
in 1950 refers to year = 1950; losing rate less than 20% refers to divide(lost, add(won, lost)) < 0.2
SELECT COUNT(DISTINCT T1.playerID) FROM players AS T1 INNER JOIN players_teams AS T2 ON T1.playerID = T2.playerID INNER JOIN teams AS T3 ON T3.tmID = T2.tmID WHERE CAST(T3.lost AS REAL) * 100 / (T3.lost + T3.won) < 20
CREATE TABLE players_teams ( PostGS INTEGER, -- PostdRebounds INTEGER, -- PostPF INTEGER, -- tmID TEXT, -- threeAttempted INTEGER, -- PostRebounds INTEGER, -- assists INTEGER, -- threeMade INTEGER, -- PostBlocks INTEGER, -- PostTurnovers INTEGER, -- GP INTEGER, -- lgID TEXT, -- Example...
superstore
Name the customers from the Eastern region whose orders cost above 80000.
cost above 80000 refers to SUTRACT(MULTIPLY(DIVIDE(Sales, SUTRACT(1, discount)), Quantity), Profit) > 80000
SELECT DISTINCT T2.`Customer Name` FROM east_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T1.Region = 'East' AND T1.Sales / (1 - T1.Discount) * T1.Quantity - T1.Profit > 80000
CREATE TABLE west_superstore ( Profit REAL, -- Region TEXT, -- Example Values: `West` | Value Statics: Total count 6406 - Distinct count 1 - Null count 0 "Product ID" TEXT, -- foreign key ("Product ID", Region) references product("Product ID",Region), "Order Date" DATE, -- foreign key ("Customer ID", Reg...
synthea
Among the patients with prediabetes, how many are female?
patients with prediabetes refer to PATIENT from conditions where DESCRIPTION = 'Prediabetes'; female refers to gender = 'F';
SELECT COUNT(DISTINCT T2.patient) FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.gender = 'F' AND T1.DESCRIPTION = 'Prediabetes'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
mondial_geo
What is the peak height of the highest volcanic type of mountain? Give it's name.
peak means the highest
SELECT Height, Name FROM mountain WHERE Type = 'volcanic' ORDER BY Height DESC LIMIT 1
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
List the products whose supplier is Pavlova, Ltd. Please include the product ID and re-order level.
"Pavlova, Ltd" is the CompanyName; products refers to ProductName
SELECT T1.ProductName, T1.ProductID, T1.ReorderLevel FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Pavlova, Ltd.'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
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 west_superstore ( Profit REAL, -- Region TEXT, -- Example Values: `West` | Value Statics: Total count 6406 - Distinct count 1 - Null count 0 "Product ID" TEXT, -- foreign key ("Product ID", Region) references product("Product ID",Region), "Order Date" DATE, -- foreign key ("Customer ID", Reg...
mondial_geo
When did the United States of America attained it's Independence?
null
SELECT T1.Independence FROM politics AS T1 INNER JOIN country AS T2 ON T1.Country = T2.Code WHERE T2.Name = 'United States'
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
Among the seafoods, how many of them have an order quantity of more than 50?
"Seafood" is the CategoryName; order quantity of more than 50 refers to Quantity > 50
SELECT COUNT(T1.ProductID) FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Categories AS T3 ON T1.CategoryID = T3.CategoryID WHERE T3.CategoryName = 'Seafood' AND T2.Quantity > 50
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
professional_basketball
Which coach has the most 'won' than 'lost' in year '1988'?
in year '1988' refers to year = 1988; the most 'won' than 'lost' refers to max(subtract(won, lost))
SELECT coachID FROM coaches WHERE year = 1988 ORDER BY won - lost DESC LIMIT 1
CREATE TABLE players_teams ( PostGS INTEGER, -- PostdRebounds INTEGER, -- PostPF INTEGER, -- tmID TEXT, -- threeAttempted INTEGER, -- PostRebounds INTEGER, -- assists INTEGER, -- threeMade INTEGER, -- PostBlocks INTEGER, -- PostTurnovers INTEGER, -- GP INTEGER, -- lgID TEXT, -- Example...
superstore
Who ordered the Bush Mission Pointe Library in the Central Region?
Bush Mission Pointe Library' is the "Product Name";
SELECT DISTINCT T2.`Customer Name` FROM central_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` INNER JOIN product AS T3 ON T3.`Product ID` = T1.`Product ID` WHERE T3.`Product Name` = 'Bush Mission Pointe Library' AND T3.Region = 'Central'
CREATE TABLE west_superstore ( Profit REAL, -- Region TEXT, -- Example Values: `West` | Value Statics: Total count 6406 - Distinct count 1 - Null count 0 "Product ID" TEXT, -- foreign key ("Product ID", Region) references product("Product ID",Region), "Order Date" DATE, -- foreign key ("Customer ID", Reg...
synthea
List down the encounter descriptions of patients who were born in Pittsfield MA US.
born in Pittsfield MA US refers to birthplace = 'Pittsfield MA US';
SELECT DISTINCT T2.DESCRIPTION FROM patients AS T1 INNER JOIN encounters AS T2 ON T1.patient = T2.PATIENT WHERE T1.birthplace = 'Pittsfield MA US'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
mondial_geo
In which city has the greatest population, what is its percentage to its country population?
null
SELECT T3.Name, CAST(T3.Population AS REAL) * 100 / T1.Population FROM country AS T1 INNER JOIN province AS T2 ON T1.Code = T2.Country INNER JOIN city AS T3 ON T3.Country = T2.Country ORDER BY T3.Population DESC LIMIT 1
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
Compute the total order quantity for Uncle Bob's Organic Dried Pears so far.
"Uncle Bob's Organic Dried Pears" is the ProductName; total order quantity refers to Sum(Quantity)
SELECT SUM(T2.Quantity) FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductName LIKE 'Uncle Bob%s Organic Dried Pears'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
professional_basketball
From 1962 to 1975, how many coaches received the award?
from 1960 to 1975 refers to year between 1960 and 1975
SELECT COUNT(DISTINCT coachID) FROM awards_coaches WHERE year BETWEEN 1962 AND 1975
CREATE TABLE players_teams ( PostGS INTEGER, -- PostdRebounds INTEGER, -- PostPF INTEGER, -- tmID TEXT, -- threeAttempted INTEGER, -- PostRebounds INTEGER, -- assists INTEGER, -- threeMade INTEGER, -- PostBlocks INTEGER, -- PostTurnovers INTEGER, -- GP INTEGER, -- lgID TEXT, -- Example...
synthea
Among the patients who were immunized with meningococcal MCV4P, how many have viral sinusitis disorder after getting the immunization?
immunized with meningococcal MCV4P refers to DESCRIPTION = 'meningococcal MCV4P' from immunizations; viral sinusitis disorder refers to DESCRIPTION = 'Viral sinusitis (disorder)' from conditions;
SELECT COUNT(DISTINCT T1.patient) FROM immunizations AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T1.DESCRIPTION = 'meningococcal MCV4P' AND T2.DESCRIPTION = 'Viral sinusitis (disorder)'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
computer_student
What is the average number of courses taught by a professor?
professor refers to professor = 1; average number of courses = divide(count(taughtBy.course_id), count(taughtBy.p_id) where professor = 1 )
SELECT CAST(COUNT(T1.course_id) AS REAL) / COUNT(DISTINCT T2.p_id) AS num FROM taughtBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.professor = 1
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_d...
mondial_geo
Provide a full list of countries and its population with more than 70% of Chinese.
null
SELECT T1.Name, T1.Population * T2.Percentage FROM country AS T1 INNER JOIN ethnicGroup AS T2 ON T1.Code = T2.Country WHERE T2.Name = 'Chinese' AND T2.Percentage > 70
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
What is the average sales for each categories?
average sales = AVG(ProductSales)
SELECT AVG(ProductSales) FROM `Sales by Category` GROUP BY CategoryName
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
superstore
Provide the names of the products with a profit greater than 98% of the average profit of all products in the East region.
names of the products refers to "Product Name";  profit greater than 98% of the average profit refers to Profit > MULTIPLY(AVG(Profit), 0.98)
SELECT DISTINCT T2.`Product Name` FROM east_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T2.Region = 'East' AND T1.Profit > ( SELECT AVG(Profit) * 0.98 FROM east_superstore )
CREATE TABLE west_superstore ( Profit REAL, -- Region TEXT, -- Example Values: `West` | Value Statics: Total count 6406 - Distinct count 1 - Null count 0 "Product ID" TEXT, -- foreign key ("Product ID", Region) references product("Product ID",Region), "Order Date" DATE, -- foreign key ("Customer ID", Reg...
mondial_geo
List the full name its capital of all the countries with parliamentary democracy government.
Parliamentary democracy is a government form
SELECT T1.Capital FROM country AS T1 INNER JOIN politics AS T2 ON T1.Code = T2.Country WHERE T2.Government = 'parliamentary democracy'
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
Write down the top ten companies with the most total sales by amount.
most total sales refers to Max(SaleAmount); companies refers to CompanyName
SELECT CompanyName FROM `Sales Totals by Amount` ORDER BY SaleAmount DESC LIMIT 10
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
synthea
Calculate the number of female patients who accepted "HPV quadrivalent" immunization.
female refers to gender = 'F'; "HPV quadrivalent" immunization refers to immunizations where DESCRIPTION = 'HPV quadrivalent';
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN immunizations AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'HPV quadrivalent' AND T1.gender = 'F'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
mondial_geo
Find the government type for the country with the highest percentage GDP in Agriculture.
null
SELECT T3.Government FROM country AS T1 INNER JOIN economy AS T2 ON T1.Code = T2.Country INNER JOIN politics AS T3 ON T3.Country = T2.Country ORDER BY T2.Agriculture DESC LIMIT 1
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
What is the full name of the Vice President of Sales. Give me the URL of his/her photo.
"Vice Present of Sales" refers to Title = 'Vice President, Sales'; full name refers to FirstName, LastName; url of photo refers to PhotoPath
SELECT FirstName, LastName FROM Employees WHERE Title = 'Vice President, Sales'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
professional_basketball
List the first name, last name and team name of players who are drafted from 'Seattle' between year 1965 to 1970.
team name refers to teams.name; drafted from 'Seattle' refers to draftFrom = 'Seattle'; between year 1965 to 1970 refers to draftYear between 1965 and 1970
SELECT DISTINCT T1.firstName, T1.lastName, T3.name FROM players AS T1 INNER JOIN draft AS T2 ON T1.playerID = T2.playerID INNER JOIN teams AS T3 ON T2.tmID = T3.tmID WHERE T2.draftFrom = 'Seattle' AND T2.draftYear BETWEEN 1965 AND 1970
CREATE TABLE players_teams ( PostGS INTEGER, -- PostdRebounds INTEGER, -- PostPF INTEGER, -- tmID TEXT, -- threeAttempted INTEGER, -- PostRebounds INTEGER, -- assists INTEGER, -- threeMade INTEGER, -- PostBlocks INTEGER, -- PostTurnovers INTEGER, -- GP INTEGER, -- lgID TEXT, -- Example...
superstore
How many orders were made by Maxwell Schwartz in 2015?
Maxwell Schwartz' is the "Customer Name"; in 2015 refers to strftime('%Y', "Order Date") = '2015';
SELECT COUNT(DISTINCT T1.`Order ID`) FROM east_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T2.`Customer Name` = 'Maxwell Schwartz' AND STRFTIME('%Y', T1.`Order Date`) = '2015'
CREATE TABLE west_superstore ( Profit REAL, -- Region TEXT, -- Example Values: `West` | Value Statics: Total count 6406 - Distinct count 1 - Null count 0 "Product ID" TEXT, -- foreign key ("Product ID", Region) references product("Product ID",Region), "Order Date" DATE, -- foreign key ("Customer ID", Reg...
synthea
Calculate the average age of patients with prediabetes care plan.
SUBTRACT(SUM(deathdate), SUM(birthdate)), COUNT(patient) where REASONDESCRIPTION = 'Prediabetes' from careplans;
SELECT CAST(SUM(CASE WHEN T1.deathdate IS NULL THEN strftime('%Y', T2.STOP) - strftime('%Y', T1.birthdate) ELSE strftime('%Y', T1.deathdate) - strftime('%Y', T1.birthdate) END) AS REAL) / COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN careplans AS T2 ON T1.patient = T2.PATIENT WHERE T2.REASONDESCRIPTION = 'P...
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
computer_student
Calculate the percentage of high-level undergraduate course.
high-level undergraduate course refers to courseLevel = 'Level_400'; percentage = divide(count(course.course_id) when courseLevel = 'Level_400', count(course.course_id)) * 100%
SELECT CAST(SUM(CASE WHEN courseLevel = 'Level_400' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) AS per FROM course
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_d...
mondial_geo
State the inflation rate of Greece.
null
SELECT T2.Inflation FROM country AS T1 INNER JOIN economy AS T2 ON T1.Code = T2.Country WHERE T1.Name = 'Greece'
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
Give me the address, home phone and salary of the Sales Manager.
"Sales Manage" is the Title
SELECT Address, HomePhone, Salary FROM Employees WHERE Title = 'Sales Manager'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
mondial_geo
What is the population of the country with the highest infant mortality rate?
null
SELECT T1.Population FROM country AS T1 INNER JOIN population AS T2 ON T1.Code = T2.Country ORDER BY T2.Infant_Mortality DESC LIMIT 1
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
Among the products, how many of them were discontinued in production?
discontinued refers to Discontinued = 1
SELECT COUNT(*) FROM Products WHERE Discontinued = 1
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
professional_basketball
List out all the coach ID who have served more than 2 different teams.
more than 2 different teams refers to count(tmID) > 2
SELECT coachID FROM coaches GROUP BY coachID HAVING COUNT(DISTINCT tmID) > 2
CREATE TABLE players_teams ( PostGS INTEGER, -- PostdRebounds INTEGER, -- PostPF INTEGER, -- tmID TEXT, -- threeAttempted INTEGER, -- PostRebounds INTEGER, -- assists INTEGER, -- threeMade INTEGER, -- PostBlocks INTEGER, -- PostTurnovers INTEGER, -- GP INTEGER, -- lgID TEXT, -- Example...
superstore
List 5 customers in the West region who had their item shipped 'Second Class.'
shipped 'Second Class.' refers to "Ship Mode" = 'Second Class'; customers refers to "Customer Name"; Region = 'West'
SELECT DISTINCT T2.`Customer Name` FROM west_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T1.Region = 'West' AND T1.`Ship Mode` = 'Second Class' LIMIT 5
CREATE TABLE west_superstore ( Profit REAL, -- Region TEXT, -- Example Values: `West` | Value Statics: Total count 6406 - Distinct count 1 - Null count 0 "Product ID" TEXT, -- foreign key ("Product ID", Region) references product("Product ID",Region), "Order Date" DATE, -- foreign key ("Customer ID", Reg...
mondial_geo
List all the name and height of all mountains in Alaska
Alaska is a province
SELECT T1.Name, T1.Height FROM mountain AS T1 INNER JOIN geo_mountain AS T2 ON T1.Name = T2.Mountain WHERE T2.Province = 'Alaska'
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
List the product ID of the top five products, by descending order, the number of quantities in stock.
by descending in number of quantity in stock refers to max(UnitsInStock)
SELECT ProductID FROM Products ORDER BY UnitsInStock DESC LIMIT 5
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
professional_basketball
Name the teams along with the coaches that went to 'Quarter Final' round in 1946.
team name refers to teams.name; coach refers to coachID; 'Quarter Final' round refers to round = 'QF'; in 1946 refers to year = 1946
SELECT DISTINCT T1.coachID, T3.name FROM coaches AS T1 JOIN series_post AS T2 ON T1.tmID = T2.tmIDWinner JOIN teams AS T3 ON T3.tmID = T1.tmID WHERE T2.round = 'QF' AND T2.year = 1946
CREATE TABLE players_teams ( PostGS INTEGER, -- PostdRebounds INTEGER, -- PostPF INTEGER, -- tmID TEXT, -- threeAttempted INTEGER, -- PostRebounds INTEGER, -- assists INTEGER, -- threeMade INTEGER, -- PostBlocks INTEGER, -- PostTurnovers INTEGER, -- GP INTEGER, -- lgID TEXT, -- Example...
superstore
Add the total profit of Patrick Gardner in the Central region.
Patrick Gardner is the "Customer Name"; Region = 'Central'
SELECT SUM(T2.Profit) FROM people AS T1 INNER JOIN central_superstore AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T1.`Customer Name` = 'Patrick Gardner' AND T1.Region = 'Central'
CREATE TABLE west_superstore ( Profit REAL, -- Region TEXT, -- Example Values: `West` | Value Statics: Total count 6406 - Distinct count 1 - Null count 0 "Product ID" TEXT, -- foreign key ("Product ID", Region) references product("Product ID",Region), "Order Date" DATE, -- foreign key ("Customer ID", Reg...
synthea
How many conditions did Tyree Eichmann have?
conditions refer to DESCRIPTION from conditions;
SELECT COUNT(DISTINCT T2.DESCRIPTION) FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Tyree' AND T1.last = 'Eichmann'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
mondial_geo
What is the height of mountain Dhaulagiri located and in which province is it located?
null
SELECT T1.Height, T2.Province FROM mountain AS T1 INNER JOIN geo_mountain AS T2 ON T1.Name = T2.Mountain WHERE T1.Name = 'Dhaulagiri'
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
Calculate the percentage of products supplied by Gai pturage over all products.
"Gai pturage" is the CompanyName; Percentage = Divide (Count(SupplierID where CompanyName = 'Gai pturage'), Count (SupplierID)) * 100
SELECT CAST(COUNT(CASE WHEN T2.CompanyName = 'Gai pturage' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.SupplierID) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
superstore
What are the total sales of the accumulated orders of Hon Valutask Swivel Chairs in the West region?
'Hon Valutask Swivel Chairs' is the "Product Name"
SELECT SUM(T1.Sales) FROM west_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T2.`Product Name` = 'Hon Valutask Swivel Chairs' AND T1.Region = 'West'
CREATE TABLE west_superstore ( Profit REAL, -- Region TEXT, -- Example Values: `West` | Value Statics: Total count 6406 - Distinct count 1 - Null count 0 "Product ID" TEXT, -- foreign key ("Product ID", Region) references product("Product ID",Region), "Order Date" DATE, -- foreign key ("Customer ID", Reg...
synthea
How many of the patients who underwent a 'bone immobilization' procedure have a driver's license?
patients who underwent a 'bone immobilization' procedure refer to PATIENT from procedures where DESCRIPTION = 'Bone immobilization'; have a driver's license refers to drivers is not null;
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN procedures AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Bone immobilization' AND T1.drivers IS NOT NULL
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
computer_student
Provide the position status and IDs of professor who advised student ID "303".
position status refers to hasPosition; IDs of professor refers to p_id_dummy; student ID "303" refers to advisedBy.p_id = 303
SELECT T2.hasPosition, T1.p_id_dummy FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id_dummy = T2.p_id WHERE T1.p_id = 303
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_d...
mondial_geo
Provide the population of the city of the 'World Tourism Organization' headquarter.
null
SELECT T2.Population FROM organization AS T1 INNER JOIN city AS T2 ON T1.City = T2.Name WHERE T1.Name = 'World Tourism Organization'
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
What is the total units on order from Exotic Liquids?
"Exotic Liquids" is the CompanyName; total unit on order = Sum(UnitsOnOrder)
SELECT SUM(T1.UnitsOnOrder) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Exotic Liquids'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
professional_basketball
List the first name, last name, height and weight of the players who has all free throw attempted successfully made.
all free throw attempted successfully made refers to ftAttempted > 0 and ftAttempted = ftMade
SELECT DISTINCT T1.firstName, T1.lastName, T1.height, T1.weight FROM players AS T1 INNER JOIN player_allstar AS T2 ON T1.playerID = T2.playerID WHERE T2.ft_attempted > 0 AND ft_attempted = ft_made
CREATE TABLE players_teams ( PostGS INTEGER, -- PostdRebounds INTEGER, -- PostPF INTEGER, -- tmID TEXT, -- threeAttempted INTEGER, -- PostRebounds INTEGER, -- assists INTEGER, -- threeMade INTEGER, -- PostBlocks INTEGER, -- PostTurnovers INTEGER, -- GP INTEGER, -- lgID TEXT, -- Example...
superstore
Provide the order ID of Frank Olsen of the South region.
Frank Olsen' is the "Customer Name"; Region = 'South'
SELECT T1.`Order ID` FROM south_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T2.Region = 'South' AND T2.`Customer Name` = 'Frank Olsen'
CREATE TABLE west_superstore ( Profit REAL, -- Region TEXT, -- Example Values: `West` | Value Statics: Total count 6406 - Distinct count 1 - Null count 0 "Product ID" TEXT, -- foreign key ("Product ID", Region) references product("Product ID",Region), "Order Date" DATE, -- foreign key ("Customer ID", Reg...
computer_student
What is the ratio of professors and students?
professors refers to professor = 1; students refers to student = 1; ratio = divide(count(person.p_id) when professor = 1, count(person.p_id) when student = 1)
SELECT CAST(SUM(CASE WHEN professor = 1 THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(CASE WHEN student = 1 THEN 1 ELSE 0 END) AS per FROM person
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_d...
mondial_geo
What is the newest established organization where Singapore is a member of?
null
SELECT T3.Name FROM country AS T1 INNER JOIN isMember AS T2 ON T1.Code = T2.Country INNER JOIN organization AS T3 ON T3.Country = T2.Country WHERE T1.Name = 'Singapore' ORDER BY T3.Established DESC LIMIT 1
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
What is the contact title for the person who supplied a product that is 10 boxes x 12 pieces.
"10 boxes x 12 pieces" is the QuantityPerUnit
SELECT T2.ContactTitle FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.QuantityPerUnit = '10 boxes x 12 pieces'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
professional_basketball
List the champion (team name) and year from year 1950 to 1960.
champion refers to round = 'F'; team name refers to teams.name; from year 1950 to 1960 refers to year between 1950 and 1960
SELECT DISTINCT T1.name, T2.year FROM teams AS T1 JOIN series_post AS T2 ON T1.tmID = T2.tmIDWinner WHERE T2.round = 'F' AND T2.year BETWEEN 1950 AND 1960
CREATE TABLE players_teams ( PostGS INTEGER, -- PostdRebounds INTEGER, -- PostPF INTEGER, -- tmID TEXT, -- threeAttempted INTEGER, -- PostRebounds INTEGER, -- assists INTEGER, -- threeMade INTEGER, -- PostBlocks INTEGER, -- PostTurnovers INTEGER, -- GP INTEGER, -- lgID TEXT, -- Example...
superstore
What is the ship date of the order by the customer named Ann Chong in the central region?
Ann Chong' is the "Customer Name"; Region = 'Central'
SELECT T2.`Ship Date` FROM people AS T1 INNER JOIN central_superstore AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T1.`Customer Name` = 'Ann Chong' AND T1.Region = 'Central'
CREATE TABLE west_superstore ( Profit REAL, -- Region TEXT, -- Example Values: `West` | Value Statics: Total count 6406 - Distinct count 1 - Null count 0 "Product ID" TEXT, -- foreign key ("Product ID", Region) references product("Product ID",Region), "Order Date" DATE, -- foreign key ("Customer ID", Reg...
synthea
Calculate the total type of allergies for German people.
type of allergies refers to DESCRIPTION from allergies; German people refer to PATIENT where ethnicity = 'german';
SELECT COUNT(DISTINCT T2.DESCRIPTION) FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T1.ethnicity = 'german'
CREATE TABLE immunizations ( foreign key (ENCOUNTER) references encounters(ID), CODE INTEGER, -- Example Values: `8`, `62`, `140`, `113`, `83` | Value Statics: Total count 13189 - Distinct count 16 - Null count 0 foreign key (PATIENT) references patients(patient), ENCOUNTER TEXT, -- PATIENT TEXT, -- DATE D...
mondial_geo
What is the border length between 'USA' and 'MEX'
null
SELECT Length FROM borders WHERE Country1 = 'MEX' AND Country2 = 'USA'
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
List down the company names that have the highest reorder level.
Highest reorder level refers to Max(ReorderLevel)
SELECT DISTINCT T2.CompanyName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.ReorderLevel = ( SELECT MAX(ReorderLevel) FROM Products )
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...
professional_basketball
Name the youngest player who ever won "Rookie of the Year".
player name refers to playerID; the youngest refers to max(birthDate); won "Rookie of the Year" refers to award = 'Rookie of the Year'
SELECT T1.firstName, T1.middleName, T1.lastName FROM players AS T1 INNER JOIN awards_players AS T2 ON T1.playerID = T2.playerID WHERE T2.award = 'Rookie of the Year' ORDER BY T1.birthDate DESC LIMIT 1
CREATE TABLE players_teams ( PostGS INTEGER, -- PostdRebounds INTEGER, -- PostPF INTEGER, -- tmID TEXT, -- threeAttempted INTEGER, -- PostRebounds INTEGER, -- assists INTEGER, -- threeMade INTEGER, -- PostBlocks INTEGER, -- PostTurnovers INTEGER, -- GP INTEGER, -- lgID TEXT, -- Example...
superstore
Give the customer segment from the West region that orders the order ID CA-2011-108189.
Region = 'West'
SELECT DISTINCT T2.Segment FROM west_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T1.Region = 'West' AND T1.`Order ID` = 'CA-2011-108189'
CREATE TABLE west_superstore ( Profit REAL, -- Region TEXT, -- Example Values: `West` | Value Statics: Total count 6406 - Distinct count 1 - Null count 0 "Product ID" TEXT, -- foreign key ("Product ID", Region) references product("Product ID",Region), "Order Date" DATE, -- foreign key ("Customer ID", Reg...
computer_student
List down all the person IDs who taught course ID of 18.
person IDs refers to taughtBy.p_id; course ID of 18  refers to taughtBy.course_id = 18
SELECT p_id FROM taughtBy WHERE course_id = 18
CREATE TABLE course ( course_id INTEGER constraint course_pk primary key, courseLevel TEXT, -- Example Values: `Level_500`, `Level_300`, `Level_400` | Value Statics: Total count 132 - Distinct count 3 - Null count 0 ); CREATE TABLE advisedBy ( p_id INTEGER, -- constraint advisedBy_pk primary key (p_id, p_id_d...
mondial_geo
Among the organizations where headquarters are in the 'USA', what is the percentage of the them are in 'Washington'?
percentage can be computed by [count(City = 'Washington') / count(all cities)] * 100%
SELECT CAST(SUM(CASE WHEN T2.City = 'Washington' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.City) FROM country AS T1 INNER JOIN organization AS T2 ON T1.Code = T2.Country WHERE T2.Country = 'USA'
CREATE TABLE politics ( Government TEXT, -- Country TEXT default '' not null primary key constraint politics_ibfk_1 references country on update cascade on delete cascade, Independence DATE, -- Dependent TEXT constraint politics_ibfk_2 references country on update cascade on delete cascade, -- Example Values: `...
retail_world
What is the contact name for product Teatime Chocolate Biscuits?
"Teatime Chocolate Biscuits" is the ProductName
SELECT T2.ContactName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.ProductName = 'Teatime Chocolate Biscuits'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), Supplier...