db_id
stringclasses
66 values
question
stringlengths
24
325
evidence
stringlengths
1
673
gold_query
stringlengths
23
804
db_schema
stringclasses
66 values
sales_in_weather
What is the item number of the product with the highest number of units sold in store number 1 on 1/1/2012?
item number refers to item_nbr; highest number of units sold refers to Max(units); store no.1 refers to store_nbr = 1; on 1/1/2012 refers to date = '2012-01-01'
SELECT item_nbr FROM sales_in_weather WHERE `date` = '2012-01-01' AND store_nbr = 1 ORDER BY units DESC LIMIT 1
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
coinmarketcap
How much was a Bitcoin on 2013/4/28?
how much refers to price; on 2013/4/28 refers to date = '2013-04-28'
SELECT T2.price FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2013-04-28' AND T1.name = 'Bitcoin'
CREATE TABLE historical ( total_supply REAL, -- high REAL, -- percent_change_7d REAL, -- open REAL, -- close REAL, -- percent_change_1h REAL, -- percent_change_24h REAL, -- num_market_pairs INTEGER, -- time_low TEXT, -- coin_id INTEGER, -- date DATE, -- time_high TEXT, -- market_cap...
video_games
What are the platform IDs of records released in 2006?
released in 1990 refers to release_year = 1990; 2000 refers to release_year = 2000;
SELECT DISTINCT T.platform_id FROM game_platform AS T WHERE T.release_year = 2006
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
soccer_2016
How many players got out by being stumped in the second innings of all matches?
got out by being stumped refers to Out_Name = 'stumped'; the second innings refers to Innings_No = 2
SELECT SUM(CASE WHEN T1.Innings_No = 2 THEN 1 ELSE 0 END) FROM Wicket_Taken AS T1 INNER JOIN Out_Type AS T2 ON T2.Out_Id = T1.Kind_Out WHERE T2.Out_Name = 'stumped'
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
sales_in_weather
For the weather station has store no.9, what was the increased percentage of the average temperature from 2012/2/2 to 2012/2/3?
store no.9 refers to store_nbr = 9; 2012/2/2 refers to date = '2012-02-02'; 2012/2/3 refers to date = '2012-02-03'; average temperature refers to tavg; increase percentage = Divide (Subtract (tavg where date = '2012-02-03', tavg where date = '2012-02-02'), tavg where date = '2012-02-02') * 100
SELECT CAST((SUM(CASE WHEN T1.`date` = '2012-02-03' THEN T1.tavg * 1 ELSE 0 END) - SUM(CASE WHEN T1.`date` = '2012-02-02' THEN T1.tavg * 1 ELSE 0 END)) AS REAL) * 100 / SUM(CASE WHEN T1.`date` = '2012-02-02' THEN T1.tavg * 1 ELSE 0 END) FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHE...
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
coinmarketcap
List the names and symbols of the coins that were added on June 14, 2013.
added on June 14, 2013 refers to date_added like '2013-06-14%'
SELECT name, symbol FROM coins WHERE date_added LIKE '2013-06-14%'
CREATE TABLE historical ( total_supply REAL, -- high REAL, -- percent_change_7d REAL, -- open REAL, -- close REAL, -- percent_change_1h REAL, -- percent_change_24h REAL, -- num_market_pairs INTEGER, -- time_low TEXT, -- coin_id INTEGER, -- date DATE, -- time_high TEXT, -- market_cap...
shakespeare
Who is the character that said "This is Illyria, lady."?
character refers to CharName; "This is Illyria, lady." refers to PlainText = 'This is Illyria, lady.'
SELECT T1.CharName FROM characters AS T1 INNER JOIN paragraphs AS T2 ON T1.id = T2.character_id WHERE T2.PlainText = 'This is Illyria, lady.'
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- Paragraph...
sales_in_weather
What percentage was the total unit sales of store no.10 to the total sales of its weather station on 2014/10/31?
store no.10 refers to store_nbr = 10; on 2014/10/31 refers to date = '2014-10-31'; percentage = Divide (Sum(units where store_nbr = 10), Sum(units)) * 100
SELECT CAST(SUM(CASE WHEN T2.store_nbr = 10 THEN units * 1 ELSE 0 END) AS REAL) * 100 / SUM(units) FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr WHERE T1.`date` = '2014-10-31'
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
coinmarketcap
Please list the names of coins that has been disappeared.
has disappeared refers to status = 'extinct'
SELECT name FROM coins WHERE status = 'extinct'
CREATE TABLE historical ( total_supply REAL, -- high REAL, -- percent_change_7d REAL, -- open REAL, -- close REAL, -- percent_change_1h REAL, -- percent_change_24h REAL, -- num_market_pairs INTEGER, -- time_low TEXT, -- coin_id INTEGER, -- date DATE, -- time_high TEXT, -- market_cap...
olympics
Tell the host city of the 1968 Winter Olympic Games.
host city refers to city_name; the 1968 Winter Olympic Games refer to games_name = '1968 Winter';
SELECT T2.city_name FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id INNER JOIN games AS T3 ON T1.games_id = T3.id WHERE T3.games_name = '1968 Winter'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NUL...
video_games
Which year has the most number of video game releases?
year that has the most number of video game releases refers to MAX(COUNT(release_year));
SELECT T1.release_year FROM ( SELECT T.release_year, COUNT(id) FROM game_platform AS T GROUP BY T.release_year ORDER BY COUNT(T.id) DESC LIMIT 1 ) T1
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
shakespeare
In the year 1500s, how many tragedies did Shakespeare write?
year 1500s refers to Date between 1500 and 1599; tragedies refers to GenreType = 'Tragedy'
SELECT COUNT(id) FROM works WHERE GenreType = 'Tragedy' AND Date BETWEEN 1500 AND 1599
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- Paragraph...
sales_in_weather
Give the station pressure status recorded by the weather station which contained no.12 store on 2012/5/15.
no.12 store refers to store_nbr = 12; on 2012/5/15 refers to date = '2012-05-15'; station pressure status refers to stnpressure
SELECT T1.stnpressure FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T1.`date` = '2012-05-15' AND T2.store_nbr = 12
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
coinmarketcap
Name the coins that have three tags.
have three tags refers to length(tag_names)-length(replace(tag_names,',','')) = 2
SELECT name FROM coins WHERE LENGTH(tag_names) - LENGTH(replace(tag_names, ',', '')) = 2
CREATE TABLE historical ( total_supply REAL, -- high REAL, -- percent_change_7d REAL, -- open REAL, -- close REAL, -- percent_change_1h REAL, -- percent_change_24h REAL, -- num_market_pairs INTEGER, -- time_low TEXT, -- coin_id INTEGER, -- date DATE, -- time_high TEXT, -- market_cap...
sales_in_weather
How many inches of total precipitation was recorded by the weather station of store no.2 on 2012/12/25?
store no.2 refers to store_nbr = 2; on 2012/12/25 refers to date = '2012-12-25'; total precipitation refers to preciptotal
SELECT T1.preciptotal FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T1.`date` = '2012-12-25' AND T2.store_nbr = 2
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
coinmarketcap
How many coins were added in May 2013? Please list the names of coins.
in May 2013 refers to year(date_added) = 2013 and month(date_added) = 5
SELECT COUNT(id) num FROM coins WHERE STRFTIME('%Y-%m', date_added) = '2013-05' UNION ALL SELECT name FROM coins WHERE STRFTIME('%Y-%m', date_added) = '2013-05'
CREATE TABLE historical ( total_supply REAL, -- high REAL, -- percent_change_7d REAL, -- open REAL, -- close REAL, -- percent_change_1h REAL, -- percent_change_24h REAL, -- num_market_pairs INTEGER, -- time_low TEXT, -- coin_id INTEGER, -- date DATE, -- time_high TEXT, -- market_cap...
video_games
In which year did the record ID 19 with game publisher ID 6657 released?
which year refers to release_year; record ID 19 refers to game platform.id; id = 19
SELECT T.release_year FROM game_platform AS T WHERE T.game_publisher_id = 6657 AND T.id = 19
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
shakespeare
What are the work numbers that are related to King Henry?
work numbers refers to works.id; related to King Henry refers to Title = '%Henry%'
SELECT id FROM works WHERE Title LIKE '%Henry%'
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- Paragraph...
soccer_2016
List the player's ID of the top five players, by descending order, in terms of bowling skill.
player's ID refers to Player_Id
SELECT Player_Id FROM Player ORDER BY Bowling_skill DESC LIMIT 5
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
sales_in_weather
Show the sea level status recorded by the weather station of store no.19 on 2013/2/24.
store no.19 refers to store_nbr = 19; on 2013/2/24 refers to date = '2013-02-24'; sea level status refers to sealevel
SELECT T1.sealevel FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T1.`date` = '2013-02-24' AND T2.store_nbr = 19
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
coinmarketcap
Please name the coin that ranked first among the coins traded on April 29, 2013.
ranked first refers to cmc_rank = 1; on April 29, 2013 refers to date = '2013-04-29'
SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2013-04-29' AND T2.cmc_rank = 1
CREATE TABLE historical ( total_supply REAL, -- high REAL, -- percent_change_7d REAL, -- open REAL, -- close REAL, -- percent_change_1h REAL, -- percent_change_24h REAL, -- num_market_pairs INTEGER, -- time_low TEXT, -- coin_id INTEGER, -- date DATE, -- time_high TEXT, -- market_cap...
video_games
Calculate the difference in sales between the games released in 1990 and 2000.
difference = SUBTRACT(SUM(num_sales WHERE release_year = 2000), SUM(num_sales WHERE release_year = 1990));
SELECT SUM(CASE WHEN T2.release_year = 2000 THEN T1.num_sales ELSE 0 END) - SUM(CASE WHEN T2.release_year = 1990 THEN T1.num_sales ELSE 0 END) FROM region_sales AS T1 INNER JOIN game_platform AS T2 ON T1.game_platform_id = T2.id
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
soccer_2016
In which venue did Kochi Tuskers Kerala play most of their matches?
Kochi Tuskers Kerala refers to Team_Name = 'Kochi Tuskers Kerala'; most of their matches refers to max(Venue_Id)
SELECT T1.Venue_Name FROM Venue AS T1 INNER JOIN Match AS T2 ON T1.Venue_Id = T2.Venue_Id INNER JOIN Team AS T3 ON T2.Team_1 = T3.Team_Id WHERE T3.Team_Name = 'Kochi Tuskers Kerala' GROUP BY T1.Venue_Name
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
sales_in_weather
Provide the code summarization for the weather recorded by the weather station which contained the no.2 store on 2013/2/12.
no.2 store refers to store_nbr = 2; on 2013/2/12 refers to date = '2013-02-12'; code summarization refers to codesum
SELECT T1.codesum FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T1.`date` = '2013-02-12' AND T2.store_nbr = 2
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
coinmarketcap
List the names of coins that cannot be traded in 2014.
cannot be tracked refers to status = 'untracked'; in 2014 refers to year(date_added) = '2014'
SELECT name FROM coins WHERE date_added LIKE '2014%' AND status = 'untracked'
CREATE TABLE historical ( total_supply REAL, -- high REAL, -- percent_change_7d REAL, -- open REAL, -- close REAL, -- percent_change_1h REAL, -- percent_change_24h REAL, -- num_market_pairs INTEGER, -- time_low TEXT, -- coin_id INTEGER, -- date DATE, -- time_high TEXT, -- market_cap...
soccer_2016
What is the average number of extra runs made as noballs?
noballs refers to Extra_Name = 'noballs' ; average number = divide(sum(Extra_Runs), count(Extra_Runs))
SELECT AVG(T1.Extra_Runs) FROM Extra_Runs AS T1 INNER JOIN Extra_Type AS T2 ON T1.Extra_Type_Id = T2.Extra_Id WHERE T2.Extra_Name = 'noballs'
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
sales_in_weather
State the number of stores that belongs to the weather station which recorded the deepest snowfall.
deepest snowfall refers to Max(snowfall); number of stores refers to store_nbr
SELECT T2.store_nbr FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr ORDER BY snowfall DESC LIMIT 1
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
coinmarketcap
What is the name of the coin with the highest price?
the highest price refers to max(price)
SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.price = ( SELECT MAX(price) FROM historical )
CREATE TABLE historical ( total_supply REAL, -- high REAL, -- percent_change_7d REAL, -- open REAL, -- close REAL, -- percent_change_1h REAL, -- percent_change_24h REAL, -- num_market_pairs INTEGER, -- time_low TEXT, -- coin_id INTEGER, -- date DATE, -- time_high TEXT, -- market_cap...
video_games
Compute the average number of sales in region ID 3.
average = AVG(MULTIPLY(num_sales, 100000));
SELECT AVG(T.num_sales * 100000) FROM region_sales AS T WHERE T.region_id = 3
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
shakespeare
In the Venus and Adonis, what is the description of the last scene listed?
Venus and Adonis refers to Title = 'Venus and Adonis'; last scene refers to max(Scene)
SELECT T2.Description FROM works AS T1 RIGHT JOIN chapters AS T2 ON T1.id = T2.work_id WHERE T1.Title = 'Venus and Adonis' ORDER BY T2.Scene DESC LIMIT 1
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- Paragraph...
sales_in_weather
Provide the sunrise time recorded by the home weather station of store no.30 on 2014/2/21.
store no. 30 refers to store_nbr = 30; on 2014/2/21 refers to date = '2014-02-21'
SELECT T1.sunrise FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T1.`date` = '2014-02-21' AND store_nbr = 30
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
coinmarketcap
What is the name of the coin that creates the most total value in the past 24 hours?
creates the most total value in the past 24 hours refers to max(volume_24h)
SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.volume_24h = ( SELECT MAX(volume_24h) FROM historical )
CREATE TABLE historical ( total_supply REAL, -- high REAL, -- percent_change_7d REAL, -- open REAL, -- close REAL, -- percent_change_1h REAL, -- percent_change_24h REAL, -- num_market_pairs INTEGER, -- time_low TEXT, -- coin_id INTEGER, -- date DATE, -- time_high TEXT, -- market_cap...
olympics
How many kinds of events belong to the sport of cycling?
kinds of events refer to event_name; sport of cycling refers to sport_name = 'Cycling';
SELECT COUNT(T2.event_name) FROM sport AS T1 INNER JOIN event AS T2 ON T1.id = T2.sport_id WHERE T1.sport_name = 'Cycling'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NUL...
video_games
Give the game name of the game ID 44.
null
SELECT T.game_name FROM game AS T WHERE T.id = 44
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
shakespeare
What is the long title of the Shakespeare's work with Act 4 Scene 5 described as "Mytilene. A street before the brothel."?
described as "Mytilene. A street before the brothel." refers to chapters.Description = 'Mytilene. A street before the brothel.'
SELECT T1.LongTitle FROM works AS T1 RIGHT JOIN chapters AS T2 ON T1.id = T2.work_id WHERE T2.Description = 'Mytilene. A street before the brothel.'
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- Paragraph...
soccer_2016
What is the name of the youngest player?
name refers to Player_Name; youngest player refers to max(DOB)
SELECT Player_Name FROM Player ORDER BY DOB DESC LIMIT 1
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
sales_in_weather
State the max temperature of the weather station which has the no.21 store on 2012/11/9.
no.21 store refers to store_nbr = 21; on 2012/11/9 refers to date = '2012-11-09'; max temperature refers to tmax
SELECT tmax FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T2.store_nbr = 21 AND T1.`date` = '2012-11-09'
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
sales_in_weather
Give the number of stores which opened on the weather station that recorded the fastest average wind speed.
fastest average wind speed refers to Max(avgspeed); number of store refers to count(store_nbr)
SELECT COUNT(T.store_nbr) FROM ( SELECT DISTINCT store_nbr FROM relation WHERE station_nbr = ( SELECT station_nbr FROM weather ORDER BY avgspeed DESC LIMIT 1 ) ) T
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
coinmarketcap
When is the highest closed price of CHNCoin?
the highest closed price refers to max(close)
SELECT T2.date FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'CHNCoin' ORDER BY T2.close DESC LIMIT 1
CREATE TABLE historical ( total_supply REAL, -- high REAL, -- percent_change_7d REAL, -- open REAL, -- close REAL, -- percent_change_1h REAL, -- percent_change_24h REAL, -- num_market_pairs INTEGER, -- time_low TEXT, -- coin_id INTEGER, -- date DATE, -- time_high TEXT, -- market_cap...
shakespeare
In Shakespeare's works between 1600 to 1610, how many of these have a character as a "Third Servingman"?
between 1600 to 1610 refers to DATE > = 1600 AND DATE < = 1610; "Third Servingman" refers to CharName = 'Third Servingman'
SELECT COUNT(DISTINCT T2.work_id) FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id INNER JOIN paragraphs AS T3 ON T2.id = T3.chapter_id INNER JOIN characters AS T4 ON T3.character_id = T4.id WHERE T1.DATE BETWEEN 1600 AND 1610 AND T4.CharName = 'Third Servingman'
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- Paragraph...
soccer_2016
In what percentage of games played at the Dr DY Patil Sports Academy venue did the winning team win by a margin of less than 10?
Dr DY Patil Sports Academy venue refers to Venue_Name = 'Dr DY Patil Sports Academy'; win by a margin of less than 10 refers to Win_Margin < 10; percentage = divide(count(Venue_Id) when Win_Margin < 10, sum(Venue_Id)) as percentage
SELECT CAST(COUNT(CASE WHEN T2.Win_Margin < 10 THEN 1 ELSE 0 END) AS REAL) * 100 / TOTAL(T1.Venue_Id) FROM Venue AS T1 INNER JOIN Match AS T2 ON T1.Venue_Id = T2.Venue_Id WHERE T1.Venue_Name = 'Dr DY Patil Sports Academy'
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
sales_in_weather
Tell the wet-bulb temperature of the weather station which contained store no.6 on 2012/2/15.
store no.6 refers to store_nbr = 6; on 2012/2/15 refers to date = '2012-02-15'; wet-bulb temperature refers to wetbulb
SELECT T1.wetbulb FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T2.store_nbr = 14 AND T1.`date` = '2012-02-15'
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
coinmarketcap
When is the best time to purchase Bitcoin?
lowest price refers to low; best time refers to date with the low;
SELECT T2.date FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'Bitcoin' ORDER BY T2.low LIMIT 1
CREATE TABLE historical ( total_supply REAL, -- high REAL, -- percent_change_7d REAL, -- open REAL, -- close REAL, -- percent_change_1h REAL, -- percent_change_24h REAL, -- num_market_pairs INTEGER, -- time_low TEXT, -- coin_id INTEGER, -- date DATE, -- time_high TEXT, -- market_cap...
video_games
How many games did BMG Interactive Entertainment release in 2012?
BMG Interactive Entertainment refers to publisher_name = 'BMG Interactive Entertainment'; release in 2012 refers to release_year = 2012;
SELECT COUNT(DISTINCT T2.game_id) FROM publisher AS T1 INNER JOIN game_publisher AS T2 ON T1.id = T2.publisher_id INNER JOIN game_platform AS T3 ON T2.id = T3.game_publisher_id WHERE T3.release_year = 2012
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
shakespeare
In "Florence. Without the walls. A tucket afar off", what is the id of the character that was mentioned in "His name, I pray you."?
"Florence. Without the walls. A tucket afar off" refers to chapters.Description = 'Florence. Without the walls. A tucket afar off.'; "His name, I pray you." refers to PlainText = 'His name, I pray you.'
SELECT T1.character_id FROM paragraphs AS T1 INNER JOIN chapters AS T2 ON T1.chapter_id = T2.id WHERE T1.PlainText = 'His name, I pray you.' AND T2.Description = 'Florence. Without the walls. A tucket afar off.'
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- Paragraph...
sales_in_weather
For the home weather station of store no.15, what was the dew point on 2012/2/18?
store no. 15 refers to store_nbr = 15; on 2012/2/18 refers to date = '2012-02-18'
SELECT T1.dewpoint FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T2.store_nbr = 15 AND T1.`date` = '2012-02-18'
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
coinmarketcap
List the names of the top five coins traded on January 1, 2014.
the top five coins refers to cmc_rank< = 5; on January 1, 2014 refers to date = '2014-01-01'
SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2014-01-01' AND T2.cmc_rank <= 5
CREATE TABLE historical ( total_supply REAL, -- high REAL, -- percent_change_7d REAL, -- open REAL, -- close REAL, -- percent_change_1h REAL, -- percent_change_24h REAL, -- num_market_pairs INTEGER, -- time_low TEXT, -- coin_id INTEGER, -- date DATE, -- time_high TEXT, -- market_cap...
video_games
Provide the name of games released in 2015.
names of games refers to game_name; released in 2015 refers to release_year = 2015;
SELECT T3.game_name FROM game_platform AS T1 INNER JOIN game_publisher AS T2 ON T1.game_publisher_id = T2.id INNER JOIN game AS T3 ON T2.game_id = T3.id WHERE T1.release_year = 2015
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
soccer_2016
How many players were born before 10/16/1975, and have a bowling skill of less than 3?
born before 10/16/1975 refers to DOB < 1975-10-16; bowling skill of less than 3 refers to Bowling_skill < 3
SELECT COUNT(*) FROM Player WHERE DOB < '1975-10-16' AND Bowling_skill < 3
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
sales_in_weather
For the weather station which recorded the highest temperature above the 30-year normal, how many stores does it have?
highest temperature above the 30-year normal refers to Max(depart)
SELECT store_nbr FROM relation WHERE station_nbr = ( SELECT station_nbr FROM weather ORDER BY depart DESC LIMIT 1 )
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
coinmarketcap
Name the coins that were not opened on May 2013.
not opened refers to open IS NULL; on May 2013 refers to year(date) = 2019 AND month(date) = 5
SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE STRFTIME('%Y-%m', T2.date) = '2013-05' AND T2.open IS NULL
CREATE TABLE historical ( total_supply REAL, -- high REAL, -- percent_change_7d REAL, -- open REAL, -- close REAL, -- percent_change_1h REAL, -- percent_change_24h REAL, -- num_market_pairs INTEGER, -- time_low TEXT, -- coin_id INTEGER, -- date DATE, -- time_high TEXT, -- market_cap...
soccer_2016
What is the total number of runs scored by the batsmen during the 2nd inning of the match ID 335988?
number of runs refers to Runs_Scored; 2nd inning refers to Innings_No = 2
SELECT SUM(Runs_Scored) FROM Batsman_Scored WHERE Match_Id = 335988 AND Innings_No = 2
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
sales_in_weather
Tell the temperature range of the home weather station of store no.7 on 2014/4/28.
store no.7 refers to tore_nbr = 7; on 2014/4/28 refers to date = '2014-04-28'; temperature range refers to Subtract (tmax, tmin)
SELECT T1.tmax - T1.tmin AS temprange FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T2.store_nbr = 7 AND T1.`date` = '2014-04-28'
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
coinmarketcap
When is Devcoin most valuable in the market?
when refers to date; most valuable refers to max(market_cap)
SELECT T2.date FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'Devcoin' ORDER BY T2.market_cap DESC LIMIT 1
CREATE TABLE historical ( total_supply REAL, -- high REAL, -- percent_change_7d REAL, -- open REAL, -- close REAL, -- percent_change_1h REAL, -- percent_change_24h REAL, -- num_market_pairs INTEGER, -- time_low TEXT, -- coin_id INTEGER, -- date DATE, -- time_high TEXT, -- market_cap...
video_games
Calculate the total sales in all regions with game platform ID 66.
total sales in all regions = MULTIPLY(SUM(num_sales), 100000);
SELECT SUM(T.num_sales) * 100000 FROM region_sales AS T WHERE T.game_platform_id = 66
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
shakespeare
What is the character and work ID of the text "Fear not thou, man, thou shalt lose nothing here."?
character refers to chapter_id; text "Fear not thou, man, thou shalt lose nothing here."  refers to PlainText = 'Fear not thou, man, thou shalt lose nothing here.'
SELECT T2.character_id, T1.work_id FROM chapters AS T1 INNER JOIN paragraphs AS T2 ON T1.id = T2.chapter_id WHERE T2.PlainText = 'Fear not thou, man, thou shalt lose nothing here.'
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- Paragraph...
sales_in_weather
Which weather station does store no.20 belong to?
store no.20 refers to store_nbr = 20; weather station refers to station_nbr
SELECT station_nbr FROM relation WHERE store_nbr = 20
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
coinmarketcap
When is the highest price of Terracoin?
when refers to date; the highest price refers to max(price)
SELECT T2.date FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'Terracoin' ORDER BY T2.price DESC LIMIT 1
CREATE TABLE historical ( total_supply REAL, -- high REAL, -- percent_change_7d REAL, -- open REAL, -- close REAL, -- percent_change_1h REAL, -- percent_change_24h REAL, -- num_market_pairs INTEGER, -- time_low TEXT, -- coin_id INTEGER, -- date DATE, -- time_high TEXT, -- market_cap...
video_games
List the games available on Wii.
games available refers to game_name; Wii refers to platform_name = 'Wii';
SELECT T4.game_name FROM platform AS T1 INNER JOIN game_platform AS T2 ON T1.id = T2.platform_id INNER JOIN game_publisher AS T3 ON T2.game_publisher_id = T3.id INNER JOIN game AS T4 ON T3.game_id = T4.id WHERE T1.platform_name = 'Wii'
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
sales_in_weather
Give the id of the weather station with most stores.
station with more stores refers to Max(Count(store_nbr)); ID of weather station refers to station_nbr
SELECT station_nbr FROM relation GROUP BY station_nbr ORDER BY COUNT(station_nbr) DESC LIMIT 1
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
coinmarketcap
When did Peercoin rank fifth?
when refers to date; rank fifth refers to cmc_rank = 5
SELECT T2.date FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'Peercoin' AND T2.cmc_rank = 5
CREATE TABLE historical ( total_supply REAL, -- high REAL, -- percent_change_7d REAL, -- open REAL, -- close REAL, -- percent_change_1h REAL, -- percent_change_24h REAL, -- num_market_pairs INTEGER, -- time_low TEXT, -- coin_id INTEGER, -- date DATE, -- time_high TEXT, -- market_cap...
video_games
What is the name of the company that produced the game titled Adventure Time: Explore the Dungeon Because I Don't Know!?
name of the company that produced the game refers to publisher_name; Adventure Time: Explore the Dungeon Because I Don't Know! Refers to game_name = 'Adventure Time: Explore the Dungeon Because I Don''t Know!';
SELECT T3.publisher_name FROM game AS T1 INNER JOIN game_publisher AS T2 ON T1.id = T2.game_id INNER JOIN publisher AS T3 ON T2.publisher_id = T3.id WHERE T1.game_name = 'Adventure Time: Explore the Dungeon Because I Don''t Know!'
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
shakespeare
Among the history works written by Shakespeare, how many works whose 1st acts have no more than 2 scenes?
history refers to GenreType = 'History' ; 1st acts  refers to Act = 1; no more than 2 scenes refers to count(Scene) < 2
SELECT COUNT(DISTINCT T2.work_id) FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id WHERE T2.Act = 1 AND T2.Scene < 2 AND T1.GenreType = 'History'
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- Paragraph...
soccer_2016
Provide the match IDs which were held on 18th April 2015.
on 18th April 2015 refers to DATE(Match_Date) = '2015-04-18'
SELECT Match_Id FROM Match WHERE Match_Date LIKE '%2015-04-18%'
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
sales_in_weather
Tell the resultant wind speed of station no.9 on 2014/1/15.
station no.9 refers to station_nbr = 9; on 2014/1/15 refers to date = '2014/01/15'; result wind speed refers to resultspeed
SELECT resultspeed FROM weather WHERE `date` = '2014-01-15' AND station_nbr = 9
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
coinmarketcap
What's the percentage of coins that is higher than the price 1 hour ago in May 29,2013? List the names of these coins.
percentage that is higher than the price 1 hour ago refers to percent_change_1h>0; in May 29,2013 refers to date = '2013-05-29'
SELECT T1.NAME FROM coins AS T1 INNER JOIN historical AS T2 ON T1.ID = T2.coin_id WHERE T2.DATE = '2013-05-29' AND T2.percent_change_1h > 0
CREATE TABLE historical ( total_supply REAL, -- high REAL, -- percent_change_7d REAL, -- open REAL, -- close REAL, -- percent_change_1h REAL, -- percent_change_24h REAL, -- num_market_pairs INTEGER, -- time_low TEXT, -- coin_id INTEGER, -- date DATE, -- time_high TEXT, -- market_cap...
olympics
When did Roma host the Olympic Games?
Roma refers to city_name = 'Roma'; When host refers to games_year;
SELECT T3.games_year FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id INNER JOIN games AS T3 ON T1.games_id = T3.id WHERE T2.city_name = 'Roma'
CREATE TABLE event ( event_name TEXT default NULL, -- sport_id INTEGER default NULL, -- foreign key (sport_id) references sport(id), id INTEGER not null primary key, ); CREATE TABLE sport ( id INTEGER not null primary key, sport_name TEXT default NULL, -- ); CREATE TABLE city ( city_name TEXT default NUL...
video_games
What percentage of games are sports?
percentage = MULTIPLY(DIVIDE(SUM(genre_name = 'sport'), COUNT(game_name)), 100.0); sports refers to genre_name = 'sport';
SELECT CAST(COUNT(CASE WHEN T1.genre_name = 'Sports' THEN T2.id ELSE NULL END) AS REAL) * 100 / COUNT(T2.id) FROM genre AS T1 INNER JOIN game AS T2 ON T1.id = T2.genre_id
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
shakespeare
In Act 1 Scene 2 of the Twelfth Night, what is the total number of of lines said by Viola?
Twelfth Night refers to Title = 'Twelfth Night'; total number of lines said by Viola refers to count(character_id) where CharName = 'Viola'
SELECT COUNT(T4.id) FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id INNER JOIN paragraphs AS T3 ON T2.id = T3.chapter_id INNER JOIN characters AS T4 ON T3.character_id = T4.id WHERE T2.Act = 1 AND T2.Scene = 2 AND T4.id = 1238 AND T4.CharName = 'Viola' AND T1.Title = 'Twelfth Night'
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- Paragraph...
sales_in_weather
Give the average temperature of station no.20 on 2014/10/17.
station no.20 refers to station_nbr = 20; on 2014/10/17 refers to date = '2014-10-17'; average temperature refers to tavg
SELECT tavg FROM weather WHERE `date` = '2014-10-17' AND station_nbr = 20
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
coinmarketcap
When was Lebowskis not opened?
when refers to date; not opened refers to open IS NULL
SELECT DISTINCT T2.date FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'Lebowskis' AND (T2.open IS NULL OR T2.open = 0)
CREATE TABLE historical ( total_supply REAL, -- high REAL, -- percent_change_7d REAL, -- open REAL, -- close REAL, -- percent_change_1h REAL, -- percent_change_24h REAL, -- num_market_pairs INTEGER, -- time_low TEXT, -- coin_id INTEGER, -- date DATE, -- time_high TEXT, -- market_cap...
video_games
Provide the name of game produced by 505 Games in 2006.
name of game refers to game_name; 505 Games refers to publisher_name = '505 Games'; in 2006 refers to release_year = 2006;
SELECT T3.game_name FROM game_platform AS T1 INNER JOIN game_publisher AS T2 ON T1.game_publisher_id = T2.id INNER JOIN game AS T3 ON T2.game_id = T3.id INNER JOIN publisher AS T4 ON T2.publisher_id = T4.id WHERE T4.publisher_name = '505 Games' AND T1.release_year = 2006
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
shakespeare
How many scenes are there in the 5th act of "History of Henry VIII"?
5th act refers to Act = 5; "History of Henry VIII" refers to LongTitle = 'History of Henry VIII'
SELECT SUM(T2.Scene) FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id WHERE T2.Act = 5 AND T1.LongTitle = 'History of Henry VIII'
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- Paragraph...
soccer_2016
How many times did the matches were held in MA Chidambaram Stadium from 5/9/2009 to 8/8/2011?
MA Chidambaram Stadium refers to Venue_Name = 'MA Chidambaram Stadium' ; from 5/9/2009 to 8/8/2011 refers to Match_Date between '2009-05-09' and '2011-08-08'
SELECT SUM(CASE WHEN Venue_Name = 'MA Chidambaram Stadium' THEN 1 ELSE 0 END) FROM `Match` AS T1 INNER JOIN Venue AS T2 ON T1.Venue_Id = T2.Venue_Id WHERE Match_Date BETWEEN '2009-05-09' AND '2011-08-08'
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
sales_in_weather
How many no.9 items from store no.11 were sold on 2012/12/7?
no. 9 item refers to item_nbr = 9; store no.11 refers to store_nbr = 11; sold on 2012/12/7 refers to date = '2012-12-07'
SELECT units FROM sales_in_weather WHERE `date` = '2012-12-07' AND store_nbr = 11 AND item_nbr = 9
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
coinmarketcap
List the names of the coins above the average price on April 28, 2013.
average price = divide(sum(price), count(name)); on April 28, 2013 refers to date = '2013-04-28'
SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2018-04-28' AND T2.price > ( SELECT AVG(price) FROM historical WHERE date = '2018-04-28' )
CREATE TABLE historical ( total_supply REAL, -- high REAL, -- percent_change_7d REAL, -- open REAL, -- close REAL, -- percent_change_1h REAL, -- percent_change_24h REAL, -- num_market_pairs INTEGER, -- time_low TEXT, -- coin_id INTEGER, -- date DATE, -- time_high TEXT, -- market_cap...
video_games
What is the total number of adventure games released in 2005?
adventure games refers to game_name WHERE genre_name = 'Adventure'; released in 2005 refers to release_year = 2005;
SELECT COUNT(DISTINCT T3.id) FROM game_platform AS T1 INNER JOIN game_publisher AS T2 ON T1.game_publisher_id = T2.id INNER JOIN game AS T3 ON T2.game_id = T3.id INNER JOIN genre AS T4 ON T3.genre_id = T4.id WHERE T4.genre_name = 'Adventure' AND T1.release_year = 2005
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
shakespeare
List the scene numbers involving the character named Sir Toby Belch in the Twelfth Night.
scene numbers refers to Scene; character named Sir Toby Belch refers to CharName = 'Sir Toby Belch'; in the Twelfth Night refers to Title = 'Twelfth Night'
SELECT DISTINCT T2.Scene FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id INNER JOIN paragraphs AS T3 ON T2.id = T3.chapter_id INNER JOIN characters AS T4 ON T3.character_id = T4.id WHERE T1.Title = 'Twelfth Night' AND T4.CharName = 'Sir Toby Belch'
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- Paragraph...
soccer_2016
Tally the player IDs of "Man of the Series" awardees for the seasons from 2011 to 2015.
seasons from 2011 to 2015 refers to 2011 < Season_Year < 2015
SELECT Man_of_the_Series FROM Season WHERE 2011 < Season_Year < 2015
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
sales_in_weather
Give the id of the bestsellers of store no.1 on 2012/1/1.
store no. 1 refers to store_nbr = 1; on 2012/1/1 refers to date = '2012-01-01'; best seller refers to Max(units); ID refers to item_nbr
SELECT item_nbr FROM sales_in_weather WHERE `date` = '2012-01-01' AND store_nbr = 1 ORDER BY units DESC LIMIT 1
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
retail_world
To whom does Nancy Davolio report? Please give that employee's full name.
to whom refers to ReportsTo; full name = FirstName, LastName;
SELECT FirstName, LastName FROM Employees WHERE EmployeeID = ( SELECT ReportsTo FROM Employees WHERE LastName = 'Davolio' AND FirstName = 'Nancy' )
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...
soccer_2016
Give me the match ID and date of the matches that were held in Kingsmead for three consecutive days.
date of the matches refers to Match_Date; held in Kingsmead refers to Venue_Name = 'Kingsmead'
SELECT T1.Match_Id, T1.Match_Date FROM `Match` AS T1 INNER JOIN Venue AS T2 ON T1.Venue_Id = T2.Venue_Id WHERE T2.Venue_Name = 'Kingsmead'
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
sales_in_weather
What is the percentage of the units of item no.5 sold among all units of items sold in store no.3 on the day with the highest max temperature in 2012?
item no. 5 refers to item_nbr = 5; store no.3 refers to store_nbr = 3; highest max temperature refers to Max(tmax); in 2012 refers to SUBSTR(date, 1, 4) = '2012';  Percentage = Divide (Sum(units where item_nbr = 5), Sum(units)) * 100
SELECT CAST(SUM(CASE WHEN T1.item_nbr = 5 THEN units * 1 ELSE 0 END) AS REAL) * 100 / SUM(units) FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr WHERE T1.store_nbr = 3 AND T1.`date` LIKE '%2012%' AND T3.tmax = ( SELECT MAX(...
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
coinmarketcap
How many times was Bytecoin traded in June 2013?
in June 2013 refers to year(date) = 2013 AND month(date) = 6
SELECT COUNT(T2.coin_id) FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'Bytecoin' AND STRFTIME('%Y-%m', T2.date) = '2013-06'
CREATE TABLE historical ( total_supply REAL, -- high REAL, -- percent_change_7d REAL, -- open REAL, -- close REAL, -- percent_change_1h REAL, -- percent_change_24h REAL, -- num_market_pairs INTEGER, -- time_low TEXT, -- coin_id INTEGER, -- date DATE, -- time_high TEXT, -- market_cap...
video_games
List down the game platform ID and region name where the games achieved 20000 sales and below.
20000 sales and below refers to num_sales < 0.2;
SELECT T2.game_platform_id, T1.region_name FROM region AS T1 INNER JOIN region_sales AS T2 ON T1.id = T2.region_id WHERE T2.num_sales * 100000 <= 20000
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
shakespeare
Among the chapters in "As You Like It", how many chapters have a paragraph number of no more than 50?
"As You Like It" refers to Title = 'As You Like It' ;paragraph number of no more than 50 refers to ParagraphNum < 50
SELECT COUNT(T3.chapter_id) FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id INNER JOIN paragraphs AS T3 ON T2.id = T3.chapter_id WHERE T1.Title = 'As You Like It' AND T3.ParagraphNum < 50
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- Paragraph...
soccer_2016
Which team wins the toss during the match ID 336011, and can you tell me whether they decided to bat or field?
wins the toss refers to Toss_Winner; whether they decided to bat or field refers to Toss_Name
SELECT T2.Toss_Name, T1.Toss_Decide, T1.Toss_Winner FROM `Match` AS T1 INNER JOIN Toss_Decision AS T2 ON T1.Toss_Decide = T2.Toss_Id WHERE T1.Match_Id = '336011'
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
sales_in_weather
How many units of item no.5 were sold in store no.3 on average on the days when the max temperature exceeded 90?
item no. 5 refers to item_nbr = 5; store no.3 refers to store_nbr = 3;  when the maximum temperature exceed 90 refers to tmax > 90; average = Divide (Sum(units), Count(date))
SELECT CAST(SUM(T1.units) AS REAL) / COUNT(T1.`date`) FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr WHERE T1.store_nbr = 3 AND T1.item_nbr = 5 AND T3.tmax > 90
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
retail_world
How many employees have obtained a doctorate?
doctorate refers to TitleOfCourtesy = 'Dr.;
SELECT COUNT(EmployeeID) FROM Employees WHERE TitleOfCourtesy = 'Dr.'
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...
soccer_2016
Between match nos. 335989 and 337000, how many times did a batsman score more than 3 runs during over no. 1, ball no. 1, and inning no. 1 of the matches?
Between match no. 335989 and 337000 refers to 335989 < Match_Id < 337000; batsman score more than 3 runs during over no. 1, ball no. 1, and inning no. 1 of the matches refers to Runs_Scored > 3 and  Over_Id = 1 and Ball_Id = 1 and Innings_No = 1
SELECT SUM(CASE WHEN Runs_Scored > 3 THEN 1 ELSE 0 END) FROM Batsman_Scored WHERE 335989 < Match_Id < 337000 AND Innings_No = 1 AND Over_Id = 1 AND Ball_Id = 1
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
sales_in_weather
On the day with the highest max temperature in 2012, how many items in store no.3 had no sales?
highest max temperature refers to Max(tmax); in 2012 refers to SUBSTR(date, 1, 4) = '2012'; store no.3 refers to store_nbr = 3; had no sale refers to units = 0
SELECT COUNT(DISTINCT T1.item_nbr) FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr AND T1.store_nbr = 3 AND SUBSTR(T1.`date`, 1, 4) = '2012' AND T1.units = 0 GROUP BY T3.tmax ORDER BY T3.tmax DESC LIMIT 1
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
retail_world
How many employees have Andrew Fuller as their direct supervisor?
direct supervisor refers to ReportsTo where the person being reported to is usually the direct supervisor of the reporter;
SELECT COUNT(EmployeeID) FROM Employees WHERE ReportsTo = ( SELECT EmployeeID FROM Employees WHERE LastName = 'Fuller' AND FirstName = 'Andrew' )
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...
video_games
How many video game publishers have Interactive in their names?
publishers that have Interactive in their names refers to publisher_name LIKE '%Interactive%';
SELECT COUNT(T.id) FROM publisher AS T WHERE T.publisher_name LIKE '%Interactive%'
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
shakespeare
What is the chapter description where the paragraph "What, wilt thou hear some music, my sweet love?" belongs?
paragraph "What, wilt thou hear some music, my sweet love?" refers to  PlainText = 'What, wilt thou hear some music, my sweet love?'
SELECT T1.id, T1.Description FROM chapters AS T1 INNER JOIN paragraphs AS T2 ON T1.id = T2.chapter_id WHERE T2.PlainText = 'What, wilt thou hear some music, my sweet love?'
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- Paragraph...
soccer_2016
Where was the ID 336005 match held? Please give me the venue and the city.
ID 336005 match refers to Match_Id = '336005'; venue refers to Venue_Name; city refers to City_Name
SELECT T2.Venue_Name, T3.City_Name FROM `Match` AS T1 INNER JOIN Venue AS T2 ON T1.Venue_Id = T2.Venue_Id INNER JOIN City AS T3 ON T2.City_Id = T3.City_Id WHERE T1.Match_Id = '336005'
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
sales_in_weather
What is the ID of the item that sold the best on the day with the highest max temperature in store no.3 in 2012?
highest max temperature refers to Max(tmax); store no.3 refers to store_nbr = 3; in 2012 refers to substring (date, 1, 4) = '2012'; sold the best refers to Max(units); ID of the item refers to item_nbr
SELECT T1.item_nbr FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr WHERE T1.store_nbr = 3 AND T1.`date` LIKE '%2012%' AND tmax = ( SELECT MAX(tmax) FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2....
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...
video_games
List the game IDs of the games produced by Abylight.
Abylight refers to publisher_name = 'Abylight';
SELECT T1.game_id FROM game_publisher AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.id WHERE T2.publisher_name = 'Abylight'
CREATE TABLE region_sales ( foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (game_platform_id) references game_platform(id), foreign key (region_id) references region(id), region_id INTEGER default NULL, -- Example Values: `1`, `...
shakespeare
How many characters are there in Hamlet?
Hamlet refers to Title = 'Hamlet'
SELECT COUNT(DISTINCT T3.character_id) FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id INNER JOIN paragraphs AS T3 ON T2.id = T3.chapter_id WHERE T1.Title = 'Hamlet'
CREATE TABLE characters ( CharName TEXT not null, -- Abbrev TEXT not null, -- Description TEXT not null, -- id INTEGER primary key autoincrement, ); CREATE TABLE paragraphs ( chapter_id INTEGER default 0 not null references chapters, -- character_id INTEGER not null references characters, -- Paragraph...
soccer_2016
Write down the name of players whose bowling skill is Legbreak.
name of players refers to Player_Name
SELECT T2.Player_Name FROM Bowling_Style AS T1 INNER JOIN Player AS T2 ON T1.Bowling_Id = T2.Bowling_skill WHERE T1.Bowling_skill = 'Legbreak'
CREATE TABLE Win_By ( Win_Id INTEGER primary key, Win_Type TEXT, -- Example Values: `runs`, `wickets`, `NO Result`, `Tie` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 ); CREATE TABLE Wicket_Taken ( Kind_Out INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `5` | Value Statics: Total count 6727 ...
sales_in_weather
How many more units of item no.16 were sold on the day with the highest max temperature in 2012 in store no.5 than in store no.10?
store no. 5 refers to store_nbr = 5; store no. 10 refers to store_nbr = 10; item no.16 refers to item_nbr = 16; in 2012 refers to SUBSTR(date, 1, 4) = '2012'; highest max temperature refers to Max(tmax); more units sold refers to Subtract ( Sum(units where store_nbr = 5), Sum(units where store_nbr = 10))
SELECT ( SELECT SUM(units) FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr WHERE T1.item_nbr = 16 AND T1.`date` LIKE '%2012%' AND T1.store_nbr = 5 GROUP BY tmax ORDER BY T3.tmax DESC LIMIT 1 ) - ( SELECT SUM(units) FROM sal...
CREATE TABLE sales_in_weather ( primary key (store_nbr, date, item_nbr), store_nbr INTEGER, -- units INTEGER, -- item_nbr INTEGER, -- date DATE, -- ); CREATE TABLE relation ( store_nbr INTEGER primary key, station_nbr INTEGER, -- foreign key (store_nbr) references sales_in_weather(store_nbr), foreig...