db_id
stringclasses
66 values
question
stringlengths
24
325
evidence
stringlengths
1
673
gold_query
stringlengths
23
804
db_schema
stringclasses
66 values
student_loan
How many male students filed for bankruptcy as compare to female students?
difference = SUBTRACT(COUNT(filed_for_bankrupcy.name who are In male.name), COUNT(filed_for_bankrupcy.name who are NOT in male.name)); male students are mentioned in male.name; female students refers to filed_for_bankrupy.name who are NOT in male.name;
SELECT COUNT(T2.name) - SUM(IIF(T2.name IS NULL, 1, 0)) AS num FROM filed_for_bankrupcy AS T1 LEFT JOIN male AS T2 ON T2.name = T1.name
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ...
superstore
What is the total profit of "Memorex Froggy Flash Drive 8 GB in south superstore?
"Memorix Froggy Flash Drive 8 GB" is the "Product Name"
SELECT SUM(T1.Profit) FROM south_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` GROUP BY T2.`Product Name` = 'Memorix Froggy Flash Drive 8 GB'
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...
cookbook
What is the percentage calories protein of Raspberry Chiffon Pie?
Raspberry Chiffon Pie refers title; percentage calories protein refers to pcnt_cal_prot
SELECT pcnt_cal_prot FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.title = 'Raspberry Chiffon Pie'
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
For the goalie who had the most shutouts in 2010, what's his catching hand?
the most shutouts refer to MAX(SHO); catching hand refers to shootCatch; year = 2010;
SELECT T2.shootCatch FROM Goalies AS T1 INNER JOIN Master AS T2 ON T1.playerID = T2.playerID WHERE T1.year = 2010 GROUP BY T2.shootCatch ORDER BY SUM(T1.SHO) DESC LIMIT 1
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
student_loan
Which male students are unemployed, disable and were absent for 5 month?
male students are mentioned in male.name; unemployed and disabled refers to unemployed.name = disabled.name; absent for 5 month refers to month = 5;
SELECT T1.name FROM unemployed AS T1 INNER JOIN disabled AS T2 ON T2.name = T1.name INNER JOIN longest_absense_from_school AS T3 ON T3.name = T2.name WHERE T3.month = 5
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ...
superstore
How many orders were made by customers who live in Texas at the Central superstore?
customer live in Texas refers to State = 'Texas'
SELECT COUNT(DISTINCT T2.`Order ID`) FROM people AS T1 INNER JOIN central_superstore AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T1.State = 'Texas'
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...
cookbook
How much fat does the Raspberry Chiffon Pie have?
Raspberry Chiffon Pie refers to title
SELECT T2.total_fat FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.title = 'Raspberry Chiffon Pie'
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
How many Haileybury Hockey Club goalies became a hall of famer?
hall of famers refers to hofID where playerID is not NULL;
SELECT COUNT(DISTINCT T1.playerID) FROM Goalies AS T1 INNER JOIN Master AS T2 ON T1.playerID = T2.playerID INNER JOIN Teams AS T3 ON T1.tmID = T3.tmID AND T1.year = T3.year WHERE T3.name = 'Haileybury Hockey Club' AND T2.hofID IS NOT NULL
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
student_loan
What is the school and organization enrolled by student211?
organization refers to organ; student211 is a name of student;
SELECT T2.school, T1.organ FROM enlist AS T1 INNER JOIN enrolled AS T2 ON T2.name = T1.name WHERE T1.name = 'student211'
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ...
cookbook
Among the recipes with sea bass, how many percent of recipes can serve 10 people and above?
sea bass is a name of an ingredient; can serve 10 people and above refers to servings > = 10; calculation = MULTIPLY(DIVIDE(COUNT(servings > = 10 THEN recipe_id)), COUNT(recipe_id), 100)
SELECT CAST(SUM(CASE WHEN T1.servings >= 10 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id WHERE T3.name = 'sea bass steak'
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
Which Minnesota North Stars' goalkeeper had the most Goal Againsts in his play time?
Goals Against are the number of goals recorded while the goalie is on the ice; the most Goal Againsts refers to MAX(GA); Minnesota North Stars is name of team;
SELECT playerID FROM Goalies AS T1 INNER JOIN Teams AS T2 ON T1.tmID = T2.tmID AND T1.year = T2.year WHERE T2.name = 'Minnesota North Stars' GROUP BY T1.playerID ORDER BY SUM(T1.GA) DESC LIMIT 1
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
student_loan
What is the percentage difference between the attendence of disabled and non-disable students? Do the disable students show better attendance than non-disable students?
difference = MULTIPLY(DIVIDE(SUBTRACT(COUNT(longest_absense_from_school.name that is in disabled.name), COUNT(longest _absense_from_school.name that is NOT in disabled.name), longest _absense_from_school.name), 100)); IF COUNT(longest_absense_from_school.name that is in disabled.name) < COUNT(longest _absense_from_scho...
SELECT CAST((SUM(IIF(T2.name IS NOT NULL AND T1.month = 0, 1, 0)) - SUM(IIF(T2.name IS NULL AND T1.month = 0, 1, 0))) AS REAL) * 100 / COUNT(T1.name), IIF(SUM(IIF(T2.name IS NOT NULL AND T1.month = 0, 1, 0)) - SUM(IIF(T2.name IS NULL AND T1.month = 0, 1, 0)) > 0, 'YES', 'NO') AS isHigh FROM longest_absense_from_school ...
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ...
superstore
List the name of all the products with order quantities greater than or equal to 10 in the central superstore that has been shipped by the slowest delivery method.
name of all the products refers to Product Name; order quantities greater than or equal to 10 refers to COUNT("Order ID") > = 10; slowest delivery refers to "Ship Mode" = 'Standard Class'
SELECT DISTINCT T2.`Product Name` FROM central_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T1.`Ship Mode` = 'Standard Class' AND T1.Quantity >= 10
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...
cookbook
Provide the title and total time of the recipe which can be made with only lima beans.
total time refers to total time refers to TOTAL(prep_min, cook_min, stnd_min); lima beans is a name of an ingredient
SELECT T1.title, T1.prep_min + T1.cook_min + T1.stnd_min FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id WHERE T3.name = 'lima beans'
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
How many goalies played for Calgary Flames?
Calgary Flames is the name of team;
SELECT COUNT(DISTINCT playerID) FROM Goalies AS T1 INNER JOIN Teams AS T2 ON T1.tmID = T2.tmID AND T1.year = T2.year WHERE T2.name = 'Calgary Flames'
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
student_loan
How many students are enlisted in the Peace Corps organization are enrolled in UCSD school?
enlisted in the Peace Corps refers to organ = 'peace_corps'; enrolled in UCSD school refers to school = 'ucsd';
SELECT COUNT(T1.name) FROM enlist AS T1 INNER JOIN enrolled AS T2 ON T1.name = T2.name WHERE T1.organ = 'peace_corps' AND T2.school = 'ucsd'
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ...
cookbook
How many recipes can be made with canned dairy?
canned dairy is a category
SELECT COUNT(*) FROM Ingredient AS T1 INNER JOIN Quantity AS T2 ON T1.ingredient_id = T2.ingredient_id WHERE T1.category = 'canned dairy'
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
In the history of all the Quebec Bulldogs, which goalie had the most play minutes for the team? Give the full name.
the most play minutes refer to MAX(Min); goalie refers to pos = 'G'; New York Islanders is the nameof team;
SELECT T2.firstName, T2.lastName FROM Goalies AS T1 INNER JOIN Master AS T2 ON T1.playerID = T2.playerID INNER JOIN Teams AS T3 ON T1.tmID = T3.tmID AND T1.year = T3.year WHERE T3.name = 'Quebec Bulldogs' AND T2.pos = 'D' GROUP BY T1.playerID, T2.firstName, T2.lastName ORDER BY SUM(T1.Min) DESC LIMIT 1
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
student_loan
Calculate the ratio of unemployed students who have never been absent from school.
ratio = CONCAT(DIVIDE(MULTIPLY(COUNT(unemployed.name WHERE month = 0), 100), COUNT(month)),'%'); unemployed students who have never been absent from school refers to (unemployed.name WHERE month = 0);
SELECT CAST(SUM(IIF(T2.month = 0, 1, 0)) AS REAL) * 100 / COUNT(T1.name) FROM unemployed AS T1 INNER JOIN longest_absense_from_school AS T2 ON T2.name = T1.name
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ...
superstore
What are the names of the products that had been shipped in March 2013 at central superstore?
names of the products refers to Product Name; shipped in March 2013 refers to "Ship Date" = '2013-03%'
SELECT DISTINCT T2.`Product Name` FROM central_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE strftime('%Y-%m', T1.`Ship Date`) = '2013-03'
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...
cookbook
List the ingredients which measure in slices.
slices refers to unit = 'slice(s)'
SELECT T1.name FROM Ingredient AS T1 INNER JOIN Quantity AS T2 ON T1.ingredient_id = T2.ingredient_id WHERE T2.unit = 'slice(s)'
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
For the goalie whose legendsID is "P196402" , how many games did he play in the league?
null
SELECT SUM(T1.GP) FROM Goalies AS T1 INNER JOIN Master AS T2 ON T1.playerID = T2.playerID WHERE T2.legendsID = 'P196402'
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
superstore
What is the product name of order CA-2011-115791 in the East superstore?
order CA-2011-115791 refers to "Order ID" = 'CA-2011-115791'
SELECT DISTINCT T2.`Product Name` FROM east_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T1.`Order ID` = 'CA-2011-141817'
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...
cookbook
Among the recipes from The California Tree Fruit Agreement, calculate the percentage of sodium-free recipes.
The California Tree Fruit Agreement is a source; calculation = MULTIPLY(DIVIDE(COUNT(sodium BETWEEN 0 AND 5 THEN recipe_id), COUNT(recipe_id)), 100)
SELECT CAST(SUM(CASE WHEN T2.sodium < 5 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.source = 'The California Tree Fruit Agreement'
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
For the goalkeeper that became a coach than a Hall of Famer, who played for BOS in 1972?
BOS refers to tmID = 'BOS'; year = 1972; became a coach than a Hall of Famer means coachID is not NULL and hofID is NULL;
SELECT T2.firstName, T2.lastName , IIF(T1.tmID = 'BOS', 'YES', 'NO') FROM Goalies AS T1 INNER JOIN Master AS T2 ON T1.playerID = T2.playerID WHERE T1.year = 1972 AND T1.tmID = 'BOS' AND T2.coachID IS NOT NULL AND T2.hofID IS NULL
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
student_loan
What is the average absent month for a unemployed male students?
average = DIVIDE(SUM(month), COUNT(unemployed.name who are in male.name)); unemployed male students refers to unemployed.name who are IN male.name;
SELECT AVG(T2.month) AS avg FROM unemployed AS T1 INNER JOIN longest_absense_from_school AS T2 ON T2.name = T1.name INNER JOIN male AS T3 ON T3.name = T2.name
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ...
superstore
What is the total sales of furniture products in the east superstore in the year 2016.
furniture products refers to Category = 'Furnitures'; in the year 2016 refers to "Order Date" BETWEEN '2016-01-01' AND '2016-12-31'
SELECT SUM(T1.Sales) FROM east_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE STRFTIME('%Y', T1.`Order Date`) = '2016' AND T2.Category = 'Furniture'
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...
cookbook
Provide the ingredients and maximum quantities of the recipe which can serve 7 people.
can serve 7 people refers to servings = 7
SELECT T3.name, T2.max_qty FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id WHERE T1.servings = 7
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
For the goalie whose last name is "Young", how many teams did he play in?
goalie is a players; teams refer to tmID;
SELECT COUNT(DISTINCT T1.tmID) FROM Goalies AS T1 INNER JOIN Master AS T2 ON T1.playerID = T2.playerID WHERE T2.lastName = 'Young'
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
superstore
What is the percentage of furniture orders that were shipped through first class in 2013 at the Central superstore?
furniture refers to Category = 'Furniture'; shipped through first class in 2013 refers to ship mode = 'first class' and "Ship Date" = '2013%'; percentage = divide(sum(Order ID) when Category = 'Furniture' and "Ship Date" = '2013%', sum(Order ID)) as percentage
SELECT CAST(SUM(CASE WHEN T1.`Ship Mode` = 'First Class' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM central_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T2.Category = 'Furniture' AND STRFTIME('%Y', T1.`Ship Date`) = '2013'
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...
cookbook
Describe the ingredients in the recipe with the highest vitamin that helps vision in dim light.
the highest vitamin that helps vision in dim light refers to MAX(vitamin_a)
SELECT T1.name FROM Ingredient AS T1 INNER JOIN Quantity AS T2 ON T1.ingredient_id = T2.ingredient_id INNER JOIN Nutrition AS T3 ON T3.recipe_id = T2.recipe_id ORDER BY T3.vitamin_a DESC LIMIT 1
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
Which was the dominant hand for the goaltender who played 32 games for QUN in 1973? Give the full name.
the dominant hand refers to shootCatch; year = 1973; tmID = 'QUN'; played 32 games refers to GP = 32;
SELECT T2.shootCatch, T2.firstName, T2.lastName FROM Goalies AS T1 INNER JOIN Master AS T2 ON T1.playerID = T2.playerID AND T1.year = 1973 WHERE T1.tmID = 'QUN' AND T1.GP = 32
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
student_loan
Calculate the average duration of absense of disabled male students.
average duration = DIVIDE(SUM(month), COUNT(month)); duration of absence refers to month; disabled male students refers to disabled.name who are IN male.name;
SELECT AVG(T1.month) FROM longest_absense_from_school AS T1 INNER JOIN disabled AS T2 ON T2.name = T1.name INNER JOIN male AS T3 ON T3.name = T2.name
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ...
superstore
How many orders were made by Alan Barnes in 2015 at the Central superstore?
in 2015 refers to "Order Date" = '2015%'
SELECT COUNT(DISTINCT T2.`Order ID`) FROM people AS T1 INNER JOIN central_superstore AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T1.`Customer Name` = 'Alan Barnes' AND STRFTIME('%Y', T2.`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...
cookbook
Name the recipes which can lead to constipation.
can lead to constipation refers to iron > 20
SELECT T1.title FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T2.iron > 20
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
Among the players who had 10 empty net goals in their career, who is the tallest? Show his full name.
10 empty net goals refer to ENG = 10; tallest refers to MAX(height);
SELECT T2.firstName, T2.lastName FROM Goalies AS T1 INNER JOIN Master AS T2 ON T1.playerID = T2.playerID WHERE T1.ENG = 10 ORDER BY T2.height DESC LIMIT 1
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
cookbook
Provide the ingredients that are rationed in the recipe with the highest carbohydrate content.
the highest carbohydrate content refers to MAX(carbo)
SELECT T1.name FROM Ingredient AS T1 INNER JOIN Quantity AS T2 ON T1.ingredient_id = T2.ingredient_id INNER JOIN Nutrition AS T3 ON T3.recipe_id = T2.recipe_id WHERE T2.max_qty = T2.min_qty ORDER BY T3.carbo DESC LIMIT 1
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
For the team that Scotty Bowman coached in 1982, how many bench minor penalties did they have that year?
bench minor penalties refer to BenchMinor; Scotty Bowman is a coach; year = 1982;
SELECT T2.BenchMinor FROM Coaches AS T1 INNER JOIN Teams AS T2 ON T1.year = T2.year AND T1.tmID = T2.tmID INNER JOIN Master AS T3 ON T1.coachID = T3.coachID WHERE T3.firstName = 'Scotty' AND T3.lastName = 'Bowman' AND T1.year = 1982
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
student_loan
State the number of students who filed for bankruptcy and have payment due.
have payment due refers to bool = 'pos';
SELECT COUNT(T1.name) FROM filed_for_bankrupcy AS T1 INNER JOIN no_payment_due AS T2 ON T2.name = T1.name WHERE T2.bool = 'pos'
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ...
superstore
What is the percentage of orders with 0.2 discount in the Central superstore were purchased by customers who live in Texas?
live in Texas refers to State = 'Texas'; percentage = divide(sum(Order ID) when Discount = 0.2, sum(Order ID)) as percentage
SELECT CAST(SUM(CASE WHEN T2.Discount = 0.2 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM people AS T1 INNER JOIN central_superstore AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T1.State = 'Texas'
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...
cookbook
How many ingredients are needed to prepare Idaho Potato Supreme?
Idaho Potato Supreme refers to title
SELECT COUNT(*) FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.title = 'Idaho Potato Supreme'
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
What is the number of players whose last name is Green that played in the league but not coached?
played in the league but not coached means playerID is not NULL and coachID is NULL;
SELECT COUNT(playerID) FROM Master WHERE lastName = 'Green' AND coachID IS NULL
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
superstore
What is the order ID of the security-Tint Envelopes product ordered on June 3, 2013, in the Central region?
Security-Tint Envelopes' refers to "Product Name"; ordered on June 3, 2013 refers to "Order Date" = '2013-06-03'
SELECT DISTINCT T1.`Order ID` FROM central_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T2.`Product Name` = 'Security-Tint Envelopes' AND T1.`Order Date` = '2013-06-03'
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...
cookbook
List the ingredients in Tomato-Cucumber Relish.
Tomato-Cucumber Relish refers to title
SELECT T3.name FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id WHERE T1.title = 'Tomato-Cucumber Relish'
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
How many hall of famers both played and coached in the league?
hall of famers refers to hofID; both played and coached means playerID is not NULL and coachID is not NULL;
SELECT COUNT(playerID) FROM Master WHERE hofID IS NOT NULL AND playerID IS NOT NULL AND coachID IS NOT NULL
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
student_loan
How many unemployed students have never been absent?
never been absent refers to month = 0;
SELECT COUNT(T2.name) FROM longest_absense_from_school AS T1 INNER JOIN unemployed AS T2 ON T2.name = T1.name WHERE T1.month = 0
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ...
cookbook
Which recipes contain almond extract?
almond extract is a name of an ingredient
SELECT T1.title FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id WHERE T3.name = 'almond extract'
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
In the year 1958, what is the total number of players that became hall of famers?
hall of famers refers to hofID; players stand for category;
SELECT COUNT(hofID) FROM HOF WHERE category = 'Player' AND year = 1958
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
superstore
List the products that were ordered by Anne McFarland from the Western store.
Anne McFarland' is the "Customer Name"; Western store refers to west_superstore; products refers to "Product Name"
SELECT DISTINCT T3.`Product Name` FROM west_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 T2.`Customer Name` = 'Anne McFarland'
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...
cookbook
Provide the title and total time of the recipe which has the highest possibility of gaining weight.
the highest possibility of gaining weight refers to MAX(total_fat); total time refers to recipe_id, total time refers to TOTAL(prep_min, cook_min, stnd_min)
SELECT T1.title, T1.prep_min + T1.cook_min + T1.stnd_min FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id ORDER BY T2.total_fat DESC LIMIT 1
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
For all the referees, who became a hall of famer in the 1970s? What's his hofID?
1970s refers to year between 1970 and 1979; referees stand for category;
SELECT name, hofID FROM HOF WHERE category = 'Builder' AND year BETWEEN 1970 AND 1979
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
cookbook
Which ingredient appeared the most in recipes? Calculate its amount of appearance in percentage.
ingredient appeared the most in recipes refers to MAX(COUNT(ingredient_id)); calculation = MULTIPLY(DIVIDE(COUNT(MAX(ingredient_id)), COUNT(ingredient_id)), 100)
SELECT T1.name, CAST(COUNT(T2.ingredient_id) AS FLOAT) * 100 / ( SELECT COUNT(T2.ingredient_id) FROM Ingredient AS T1 INNER JOIN Quantity AS T2 ON T2.ingredient_id = T1.ingredient_id ) AS "percentage" FROM Ingredient AS T1 INNER JOIN Quantity AS T2 ON T2.ingredient_id = T1.ingredient_id GROUP BY T2.ingredient_id ORDER ...
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
Who was the latest non player/builder to become the hall of famer? Give the full name.
latest refers to MAX(year); non player/builder refers to category = NOT IN ('player', 'builder');
SELECT name FROM HOF WHERE category IN ('Player', 'Builder') ORDER BY year DESC LIMIT 1
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
student_loan
State the number of disabled students who have payment due.
have payment due refers to bool = 'pos';
SELECT COUNT(T1.name) FROM no_payment_due AS T1 INNER JOIN disabled AS T2 ON T1.name = T2.name WHERE T1.bool = 'neg'
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ...
superstore
Please give the name of customers from the West region that bought exactly 8 items in their purchase.
name of customers refers to "Customer Name"; bought exactly 8 items refers to Quantity = 8
SELECT DISTINCT T2.`Customer Name` FROM west_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T1.Quantity = 8 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...
cookbook
Which recipe has the highest number of ingredients? Calculate the said recipe's total time of cooking.
the highest number of ingredients refers to MAX(ingredient_id); total time refers to recipe_id, total time of cooking refers to TOTAL(prep_min, cook_min, stnd_min)
SELECT T2.recipe_id, T1.prep_min + T1.cook_min + T1.stnd_min FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id GROUP BY T2.recipe_id ORDER BY COUNT(T2.ingredient_id) DESC LIMIT 1
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
What is the percentage of American coaches among all the coaches who taught the Montreal Canadiens?
American refers to birthCountry = 'USA'; DIVIDE(COUNT(coachID where birthCountry = 'USA', name` = 'Montreal Canadiens'), COUNT(coachID where name` = 'Montreal Canadiens')) as percentage;
SELECT SUM(CAST(T2.W AS REAL) / T2.G) / SUM(T2.G + T2.W) FROM Teams AS T1 INNER JOIN TeamsSC AS T2 ON T1.tmID = T2.tmID AND T1.year = T2.year WHERE T1.name = 'Montreal Canadiens'
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
superstore
Who order from the west region on August 12, 2013, and received a discount of 0.2?
Who refers to "Customer Name"; on August 12, 2013 refers to "Order Date" = '2013-08-12'; discount of 0.2 refers to discount = 0.2
SELECT DISTINCT T2.`Customer Name` FROM west_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T1.`Order Date` = '2013-08-12' AND T1.Discount = 0.2 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...
cookbook
Among the recipes whose source is the National Potato Board, which recipe has the highest calories?
the National Potato Board is a source; the highest calories refers to MAX(calories)
SELECT T1.title FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.source = 'National Potato Board' ORDER BY T2.calories DESC LIMIT 1
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
What is the average winning rate of the Montreal Canadiens in the Stanley Cup finals?
DIVIDE(SUM(DIVIDE(W,G), COUNT(oppID);
SELECT SUM(T2.W / T2.G) / SUM(T2.G + T2.W) FROM Teams AS T1 INNER JOIN TeamsSC AS T2 ON T1.tmID = T2.tmID AND T1.year = T2.year WHERE T1.name = 'Montreal Canadiens'
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
student_loan
State the number of male students who do not have payment due.
do not have payment due refers to bool = 'neg';
SELECT COUNT(T1.name) FROM no_payment_due AS T1 INNER JOIN male AS T2 ON T2.name = T1.name WHERE T1.bool = 'pos'
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ...
superstore
List the product's name bought by the customer named Bill Shonely from the Central region.
null
SELECT DISTINCT T3.`Product Name` FROM people AS T1 INNER JOIN central_superstore AS T2 ON T1.`Customer ID` = T2.`Customer ID` INNER JOIN product AS T3 ON T3.`Product ID` = T2.`Product ID` WHERE T1.`Customer Name` = 'Bill Shonely' 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...
cookbook
How many servings does the recipe with the highest unsaturated fat have?
with the highest unsaturated fat refers MAX(SUBTRACT(total_fat, sat_fat))
SELECT COUNT(T1.title) FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id ORDER BY T2.total_fat - T2.sat_fat DESC LIMIT 1
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
How many penalty minutes did the Montreal Canadiens have on average in the Stanley Cup Finals?
AVG(PIM) = DIVIDE(SUM(PIM), COUNT(G)); Montreal Canadiens is name of team;
SELECT CAST(SUM(T2.PIM) AS REAL) / COUNT(T2.PIM) FROM Teams AS T1 INNER JOIN TeamsSC AS T2 ON T1.tmID = T2.tmID AND T1.year = T2.year WHERE T1.name = 'Montreal Canadiens'
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
student_loan
List out the number of disabled students who enlisted in marines.
marines refers to organ = 'marines';
SELECT COUNT(T1.name) FROM disabled AS T1 INNER JOIN enlist AS T2 ON T1.name = T2.name WHERE T2.organ = 'marines'
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ...
cookbook
Among the recipes with alcohol content over 10, which recipe takes the longest to prepare?
with alcohol content over 10 refers to alcohol > 10; takes the longest to prepare refers to MAX(prep_min)
SELECT T1.title FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T2.alcohol > 10 ORDER BY T1.prep_min DESC LIMIT 1
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
What is the average winning rate of the Buffalo Sabres in 2000?
DIVIDE(SUM(DIVIDE(W,G), COUNT(oppID) where year = 2000; Montreal Canadiens is name of team;
SELECT SUM(CAST(T2.W AS REAL) / T2.G) / COUNT(T1.oppID) FROM TeamVsTeam AS T1 INNER JOIN Teams AS T2 ON T1.year = T2.year AND T1.tmID = T2.tmID WHERE T2.name = 'Buffalo Sabres' AND T1.year = 2000
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
student_loan
What is the status of payment of student 124?
status of payment is mentioned in no_payment_due; bool = 'pos' means the student has payment due; bool = 'neg' means the student has no payment due; student124 is a name of student;
SELECT `bool` FROM no_payment_due WHERE name = 'student124'
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ...
superstore
Who is the customer with an order shipped on March 5, 2013, in the eastern region?
Who is the customer refers to Customer Name; shipped on March 5, 2013 refers to "Ship Date" = '2013-03-05'; eastern region refers to Region = 'East'
SELECT DISTINCT T2.`Customer Name` FROM east_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T1.`Ship Date` = '2013-03-05'
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...
cookbook
What are the optional ingredients for Warm Chinese Chicken Salad?
optional refers to optional = 'TRUE'; Warm Chinese Chicken Salad refers to title
SELECT T3.name FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id WHERE T1.title = 'Warm Chinese Chicken Salad' AND T2.optional = 'TRUE'
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
Which coach was the first one to teach the Montreal Canadiens, please give his first name.
the first one refers to MIN(year);
SELECT T3.firstName FROM Coaches AS T1 INNER JOIN Teams AS T2 ON T1.tmID = T2.tmID AND T1.year = T2.year INNER JOIN Master AS T3 ON T1.coachID = T3.coachID WHERE T2.name = 'Montreal Canadiens' ORDER BY T1.year LIMIT 1
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
student_loan
State name of students who have been absent for 5 months from school and do not have payment due.
absent for 5 months refers to month = 5; do not have payment due refers to bool = 'neg';
SELECT T1.name FROM longest_absense_from_school AS T1 INNER JOIN no_payment_due AS T2 ON T1.name = T2.name WHERE T1.month = 5 AND T2.bool = 'neg'
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ...
superstore
What product category got the highest profit in the south superstore?
highest profit refers to MAX(Profit)
SELECT T2.Category FROM south_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` 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...
cookbook
List all the ingredients for Strawberry Sorbet.
Strawberry Sorbet refers to title
SELECT T3.name FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id WHERE T1.title = 'Strawberry Sorbet'
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
In which year did the Montreal Canadiens have 49 penalty minutes in the Stanley Cup finals? Was it 1924, 1923 or 1918?
penalty minutes refer to PIM = 49;
SELECT T1.year FROM Teams AS T1 INNER JOIN TeamsSC AS T2 ON T1.tmID = T2.tmID AND T1.year = T2.year WHERE T1.name = 'Montreal Canadiens' AND T2.PIM = 49
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
student_loan
List out the number of students who filed for bankruptcy and enlisted in navy.
navy refers to organ = 'navy';
SELECT COUNT(T1.name) FROM enlist AS T1 INNER JOIN filed_for_bankrupcy AS T2 ON T1.name = T2.name WHERE T1.organ = 'navy'
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ...
cookbook
How many baking product ingredients are there in the No-Bake Chocolate Cheesecake?
baking product is a category; No-Bake Chocolate Cheesecake refers to title;
SELECT COUNT(*) FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id WHERE T3.category = 'baking products' AND T1.title = 'No-Bake Chocolate Cheesecake'
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
In the year that the Montreal Canadiens had 24 penalty minutes in the Stanley Cup finals, how many wins did the team had in total?
penalty minutes refer to PIM = 24; wins refer to W;
SELECT T2.W FROM Teams AS T1 INNER JOIN TeamsSC AS T2 ON T1.tmID = T2.tmID AND T1.year = T2.year WHERE T1.name = 'Montreal Canadiens' AND T2.PIM = 24
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
superstore
Who ordered the order ID CA-2011-118976 from the East region?
Who refers to "Customer Name"
SELECT DISTINCT T2.`Customer Name` FROM east_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T1.`Order ID` = 'CA-2011-118976' AND T2.Region = 'East'
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...
cookbook
Which ingredient appeared the least in recipes?
ingredient appeared the least in recipes refers to MIN(ingredient_id)
SELECT T1.name FROM Ingredient AS T1 INNER JOIN Quantity AS T2 ON T1.ingredient_id = T2.ingredient_id GROUP BY T2.ingredient_id ORDER BY COUNT(T2.ingredient_id) ASC LIMIT 1
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
How many penalty minutes did the Montreal Canadiens have in the 1918's Stanley Cup Finals?
penalty minutes refer to PIM; year = 1918; Montreal Canadiens is name of team;
SELECT T2.PIM FROM Teams AS T1 INNER JOIN TeamsSC AS T2 ON T1.tmID = T2.tmID AND T1.year = T2.year WHERE T1.name = 'Montreal Canadiens' AND T1.year = 1918
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
superstore
Among the customers from Houston, Texas, what is the total profit of their orders in the Central region?
customers from Houston, Texas refers to State = 'Texas' and City = 'Houston'; total profit = sum(Profit)
SELECT SUM(T2.Profit) FROM people AS T1 INNER JOIN central_superstore AS T2 ON T1.`Customer ID` = T2.`Customer ID` INNER JOIN product AS T3 ON T3.`Product ID` = T2.`Product ID` WHERE T1.City = 'Houston' AND T1.State = 'Texas' 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...
cookbook
What are the names of the top 5 recipes that are best for wound healing?
names of the recipes refers to title; best for wound healing refers to MAX(vitamin_c)
SELECT T1.title FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id ORDER BY T2.vitamin_c DESC LIMIT 5
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
Please list the names of all the teams that have played against the Buffalo Sabres.
teams that have played against refer to oppID; Buffalo Sabres is the name of team;
SELECT DISTINCT T3.name FROM TeamVsTeam AS T1 INNER JOIN Teams AS T2 ON T1.year = T2.year AND T1.oppID = T2.tmID INNER JOIN Teams AS T3 ON T1.year = T3.year AND T1.tmID = T3.tmID WHERE T2.name = 'Buffalo Sabres'
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
student_loan
State name of students who have the longest duration of absense from school and do not have payment due.
longest duration of absence from school refers to MAX(month); do not have payment due refers to bool = 'neg';
SELECT T1.name FROM longest_absense_from_school AS T1 INNER JOIN no_payment_due AS T2 ON T1.name = T2.name WHERE T2.bool = 'neg' ORDER BY T1.month DESC LIMIT 1
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ...
superstore
List down the sales, profit, and subcategories of the product ordered in the order ID US-2011-126571 in the East region.
null
SELECT T1.Sales, T1.Profit, T2.`Sub-Category` FROM east_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T1.`Order ID` = 'US-2011-126571' AND T2.Region = 'East'
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...
cookbook
How many ingredients are there in the recipe that is best in helping your body's natural defence against illness and infection?
best in helping your body's natural defence against illness and infection refers to MAX(vitamin_a);
SELECT COUNT(*) FROM Nutrition AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.vitamin_a > 0
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
In the year 2000, which team has played the most games against the Buffalo Sabres?
which team played the most games against refers to oppID where MAX(SUM(G); Buffalo Sabres is the name of team;
SELECT T3.name FROM TeamVsTeam AS T1 INNER JOIN Teams AS T2 ON T1.year = T2.year AND T1.oppID = T2.tmID INNER JOIN Teams AS T3 ON T1.year = T3.year AND T1.tmID = T3.tmID WHERE T1.year = 2000 AND T2.name = 'Buffalo Sabres' GROUP BY T3.name ORDER BY SUM(T2.G) DESC LIMIT 1
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
student_loan
List out the number of students who have the longest duration of absense from school and enlisted in the peace corps.
longest duration of absence refers to MAX(month); peace corps refers to organ = 'peace_corps';
SELECT COUNT(T1.NAME) FROM longest_absense_from_school AS T1 INNER JOIN enlist AS T2 ON T1.name = T2.name WHERE T2.organ = 'peace_corps' ORDER BY T1.month DESC LIMIT 1
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ...
cookbook
What are the names of the ingredients that need to be cook in beef broth?
'cook in beef broth' refers to a preparation
SELECT T1.name FROM Ingredient AS T1 INNER JOIN Quantity AS T2 ON T1.ingredient_id = T2.ingredient_id WHERE T2.preparation = 'cooked in beef broth'
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
Among the coaches who taught the teams in 1922's Stanley Cup finals, how many of them are from the USA?
from the USA refers to birthCountry = 'USA'; year = 1922;
SELECT COUNT(DISTINCT T3.coachID) FROM Coaches AS T1 INNER JOIN TeamsSC AS T2 ON T1.year = T2.year AND T1.tmID = T2.tmID INNER JOIN Master AS T3 ON T1.coachID = T3.coachID WHERE T2.year = 1922 AND T3.birthCountry = 'USA'
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
superstore
Among the orders from 2016 in the Central region, what is the product with the lowest profit?
orders from 2016 refers to "Order Date" = '2016%'; product refers to "Product Name"; lowest profit refers to min(Profit)
SELECT T2.`Product Name` FROM central_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T2.Region = 'Central' AND STRFTIME('%Y', T1.`Order Date`) = '2016' ORDER BY T1.Profit ASC 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...
cookbook
How many ingredients are there in Apricot Yogurt Parfaits?
Apricot Yogurt Parfaits refers to title
SELECT COUNT(*) FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.title = 'Apricot Yogurt Parfaits'
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
Please list the nick names of the coaches who are from the USA and have taught the Buffalo Sabres.
from the USA refers to birthCountry = 'USA'; nick names of the coaches refer to nameNick where coachID is not NULL ; Buffalo Sabres is the name of team;
SELECT DISTINCT nameNick FROM Coaches AS T1 INNER JOIN Teams AS T2 ON T1.year = T2.year AND T1.tmID = T2.tmID INNER JOIN Master AS T3 ON T1.coachID = T3.coachID WHERE T2.name = 'Buffalo Sabres' AND T3.birthCountry = 'USA'
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
student_loan
Calculate the ratio of disabled students who have never been absent from school.
ratio = MULTIPLY(DIVIDE(SUM(month = 0), COUNT(disabled.name)), 100); never been absent from school refers to month = 0;
SELECT 100 * SUM(IIF(T2.month = 0, 1, 0)) AS num FROM disabled AS T1 INNER JOIN longest_absense_from_school AS T2 ON T1.name = T2.name
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ...
superstore
Provide the product's name of the product with the highest sales in the South region.
highest sales refers to max(Sales)
SELECT T2.`Product Name` FROM south_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T2.Region = 'South' 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...
cookbook
What are the names of the recipes that will cause stomach pain?
cause stomach pain refers to iron > 20
SELECT T1.title FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T2.iron > 20
CREATE TABLE Quantity ( ingredient_id INTEGER, -- quantity_id INTEGER primary key, min_qty REAL, -- foreign key (ingredient_id) references Ingredient(ingredient_id), foreign key (recipe_id) references Nutrition(recipe_id), foreign key (recipe_id) references Nutrition(recipe_id), unit TEXT, -- foreign key ...
hockey
How many coaches who have taught the Buffalo Sabres have died?
have died means deathYear is not NULL; Buffalo Sabres is the name of team;
SELECT COUNT(DISTINCT T3.coachID) FROM Coaches AS T1 INNER JOIN Teams AS T2 ON T1.year = T2.year AND T1.tmID = T2.tmID INNER JOIN Master AS T3 ON T1.coachID = T3.coachID WHERE T2.name = 'Buffalo Sabres' AND T3.deathYear IS NOT NULL
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value S...
student_loan
How many of the students joined two organization?
joined two organization refers to COUNT(organ) > = 2
SELECT COUNT(name) FROM enlist WHERE organ >= 2
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ...
superstore
List the customer's name from the South region with a standard class ship mode and sales greater than the 88% of the average sales of all orders.
sales greater than the 88% of the average sales of all orders refers to Sales > avg(Sales) * 0.88; South region refers to south_superstore
SELECT DISTINCT T2.`Customer Name` FROM south_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` WHERE T2.Region = 'South' AND T1.`Ship Mode` = 'Standard Class' AND 100 * T1.Sales / ( SELECT AVG(Sales) FROM south_superstore ) > 88
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...