db_id
stringclasses
69 values
schema
stringclasses
69 values
m_schema
stringclasses
69 values
question
stringlengths
24
325
sql
stringlengths
23
804
evidence
stringlengths
0
673
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Indicate the name of the country with a population greater than 10000 in 2010.
SELECT DISTINCT T1.county FROM country AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.population_2010 > 10000
population greater than 10000 in 2010 refers to population_2010 > 10000;
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Name the country with the largest number of households in a residential area.
SELECT T1.county FROM country AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code GROUP BY T1.county ORDER BY T2.households DESC LIMIT 1
the largest number of households refers to MAX(households);
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Calculate the percentage of households in residential areas of countries over 10000.
SELECT CAST(COUNT(CASE WHEN T2.households > 10000 THEN T1.zip_code ELSE NULL END) AS REAL) * 100 / COUNT(T1.zip_code) FROM country AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code
DIVIDE(SUM(households > 10000), SUM(households)) as percentage;
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Among the types of postal points in Saint Croix, what percentage of postal points is the post office?
SELECT CAST(COUNT(CASE WHEN T2.type = 'Post Office' THEN T1.zip_code ELSE NULL END) AS REAL) * 100 / COUNT(T1.zip_code) FROM country AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.county = 'SAINT CROIX'
DIVIDE(COUNT(type = 'Post Office' ), COUNT(type)) as percentage where county = 'SAINT CROIX';
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Among the area code 787, list the country of the cities with a postal point type of unique postal office.
SELECT DISTINCT T2.county FROM area_code AS T1 INNER JOIN country AS T2 ON T1.zip_code = T2.zip_code INNER JOIN zip_data AS T3 ON T1.zip_code = T3.zip_code WHERE T1.area_code = '787' AND T3.type = 'Unique Post Office'
postal point type of unique postal office refers to type = 'Unique Post Office';
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
What is the elevation of the city with the alias East Longmeadow?
SELECT T2.elevation FROM alias AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.alias = 'East Longmeadow'
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
In cities that do not implement daylight savings, what is the total number of cities?
SELECT COUNT(T1.area_code) FROM area_code AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.daylight_savings = 'No'
do not implement daylight savings refers to daylight_savings = 'No';
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Give the country and area code of the city with zip code 1116.
SELECT T2.county, T1.area_code FROM area_code AS T1 INNER JOIN country AS T2 ON T1.zip_code = T2.zip_code WHERE T1.zip_code = 1116
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Among the cities with alias St Thomas, provide the type of postal point for each city.
SELECT DISTINCT T2.type FROM alias AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.alias = 'St Thomas'
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
List down the names of the cities belonging to Noble, Oklahoma.
SELECT T3.city FROM state AS T1 INNER JOIN country AS T2 ON T1.abbreviation = T2.state INNER JOIN zip_data AS T3 ON T2.zip_code = T3.zip_code WHERE T1.name = 'Oklahoma' AND T2.county = 'NOBLE'
the county of Noble is located in the state of Oklahoma;
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Among the listed cities, provide the area code of the city with the largest water area.
SELECT T1.area_code FROM area_code AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.water_area = ( SELECT MAX(water_area) FROM zip_data )
the largest water area refers to MAX(water_area);
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Provide the alias of the city with the highest population in year 2020.
SELECT T1.alias FROM alias AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.population_2020 = ( SELECT MAX(population_2020) FROM zip_data )
the highest population in year 2020 refers to MAX(population_2020);
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
What is the elevation of the city belonging to Hampden, Massachusetts?
SELECT T3.elevation FROM state AS T1 INNER JOIN country AS T2 ON T1.abbreviation = T2.state INNER JOIN zip_data AS T3 ON T2.zip_code = T3.zip_code WHERE T1.name = 'Massachusetts' AND T2.county = 'HAMPDEN' GROUP BY T3.elevation
the county of Hampden is located in the state of Massachusetts.
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
List the area code of the city with the highest Hispanic population.
SELECT T1.area_code FROM area_code AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.hispanic_population = ( SELECT MAX(hispanic_population) FROM zip_data )
the highest Hispanic population refers to MAX(hispanic_population);
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Give the alias of the cities with an Asian population of 7.
SELECT T1.alias FROM alias AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.asian_population = 7
Asian population of 7 refers to asian_population = 7;
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
What is the average of the white population in the cities with area code 920?
SELECT AVG(T2.white_population) FROM area_code AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.area_code = 920
AVG(white_population) where area_code = 920;
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Among the cities with alias Ponce, what is the percentage of cities with a country level FIPS code of less than 20?
SELECT CAST(COUNT(CASE WHEN T2.county_fips < 20 THEN T2.zip_code ELSE NULL END) AS REAL) * 100 / COUNT(T2.zip_code) FROM alias AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.alias = 'Ponce'
DIVIDE(COUNT(county_fips < 20), COUNT(county_fips)) as percentage where alias = 'Ponce';
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
List down the country of the cities with a population greater than 97% of the average population of all countries in 2020.
SELECT T1.county FROM country AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.population_2020 > 0.97 * ( SELECT AVG(population_2020) FROM zip_data )
population_2020 > MULTIPLY(0.97, AVG(population_2020));
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Count the number of postal points in the district represented by Kirkpatrick Ann.
SELECT COUNT(T2.zip_code) FROM congress AS T1 INNER JOIN zip_congress AS T2 ON T1.cognress_rep_id = T2.district WHERE T1.first_name = 'Kirkpatrick' AND T1.last_name = 'Ann'
postal points refer to zip_code;
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Provide the zip codes and coordinates of the postal points under Allentown-Bethlehem-Easton, PA-NJ.
SELECT T2.zip_code, T2.latitude, T2.longitude FROM CBSA AS T1 INNER JOIN zip_data AS T2 ON T1.CBSA = T2.CBSA WHERE T1.CBSA_name = 'Allentown-Bethlehem-Easton, PA-NJ'
coordinates refer to latitude and longitude; under Allentown-Bethlehem-Easton, PA-NJ refers to CBSA_name = 'Allentown-Bethlehem-Easton, PA-NJ';
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Provide the zip codes, cities, and locations of the postal points that have Shared Reshipper as a bad alias.
SELECT T1.zip_code, T2.city, T2.latitude, T2.longitude FROM avoid AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.bad_alias = 'Shared Reshipper'
latitude and longitude coordinates can be used to identify the location;
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Who are the congress representatives of the postal points in Garfield?
SELECT T3.first_name, T3.last_name FROM zip_data AS T1 INNER JOIN zip_congress AS T2 ON T1.zip_code = T2.zip_code INNER JOIN congress AS T3 ON T2.district = T3.cognress_rep_id WHERE T1.city = 'Garfield'
Who are the congress representatives refer to first_name, last_name; Garfield is the city;
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Count the number of postal points under New York-Newark-Jersey City, NY-NJ-PA.
SELECT COUNT(T2.zip_code) FROM CBSA AS T1 INNER JOIN zip_data AS T2 ON T1.CBSA = T2.CBSA WHERE T1.CBSA_name = 'New York-Newark-Jersey City, NY-NJ-PA'
postal points refer to zip_code; under New York-Newark-Jersey City, NY-NJ-PA refers to CBSA_name = 'New York-Newark-Jersey City, NY-NJ-PA';
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
How many postal points are there under the congress representative in Puerto Rico?
SELECT COUNT(T2.zip_code) FROM congress AS T1 INNER JOIN zip_congress AS T2 ON T1.cognress_rep_id = T2.district WHERE T1.state = 'Puerto Rico'
postal points refer to zip_code; Puerto Rico refers to state = 'Puerto Rico';
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Describe the number of postal points and the countries in West Virginia.
SELECT COUNT(DISTINCT T2.zip_code), COUNT(DISTINCT T2.county) FROM state AS T1 INNER JOIN country AS T2 ON T1.abbreviation = T2.state WHERE T1.name = 'West Virginia'
postal points refer to zip_code; West Virginia is the name of the state, in which name = 'West Virginia';
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Provide the zip codes and area codes of the postal points with the community post office type at the elevation above 6000.
SELECT T1.zip_code, T1.area_code FROM area_code AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.type = 'Community Post Office ' AND T2.elevation > 6000
community post office type refers to type = 'Community Post Office'; elevation above 6000 refers to elevation > 6000;
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
How many postal points are there under the congress representative from the House of Representatives in Mississippi?
SELECT COUNT(T2.zip_code) FROM congress AS T1 INNER JOIN zip_congress AS T2 ON T1.cognress_rep_id = T2.district WHERE T1.state = 'Mississippi'
postal points refer to zip_code; Mississippi is the name of the state, in which name = 'Mississippi';
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Provide the congress representatives' IDs of the postal points in East Springfield.
SELECT T2.district FROM zip_data AS T1 INNER JOIN zip_congress AS T2 ON T1.zip_code = T2.zip_code WHERE T1.city = 'East Springfield'
congress representatives' IDs refer to CID; East Springfield is the city;
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Who is the CBSA officer of the post point in the area with the highest number of employees?
SELECT T1.CBSA_name FROM CBSA AS T1 INNER JOIN zip_data AS T2 ON T1.CBSA = T2.CBSA WHERE T2.employees = ( SELECT MAX(employees) FROM zip_data )
CBSA officer refers to CBSA_name; the highest number of employees refers to MAX(employees);
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
How many postal points with unique post office types are there in Ohio?
SELECT COUNT(T2.zip_code) FROM state AS T1 INNER JOIN zip_data AS T2 ON T1.abbreviation = T2.state WHERE T1.name = 'Ohio' AND T2.type = 'Unique Post Office'
postal points refer to zip_code; unique post office types refer to type = 'Unique Post Office'; Ohio is the name of the state, in which name = 'Ohio';
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Calculate the average number of beneficiaries per postal point in Guam.
SELECT CAST(SUM(T2.total_beneficiaries) AS REAL) / COUNT(T2.zip_code) FROM state AS T1 INNER JOIN zip_data AS T2 ON T1.abbreviation = T2.state WHERE T1.name = 'Guam'
DIVIDE(SUM(total_beneficiaries), COUNT(zip_code)) where name = 'Guam';
address
CREATE TABLE CBSA ( CBSA INTEGER primary key, CBSA_name TEXT, CBSA_type TEXT ); CREATE TABLE state ( abbreviation TEXT primary key, name TEXT ); CREATE TABLE congress ( cognress_rep_id TEXT primary key, first_name TEXT, last_name ...
【DB_ID】 address 【Schema】 # Table: main.CBSA [ (CBSA:INTEGER, Primary Key, Examples: [10300, 10380, 10420]), (CBSA_name:TEXT, Examples: [Adrian, MI]), (CBSA_type:TEXT, Examples: [Micro, Metro]) ] # Table: main.alias [ (zip_code:INTEGER, Primary Key, Examples: [501, 544, 601]), (alias:TEXT, Examples: [Holtsville, Adjunta...
Calculate the percentage of congress representatives from the Democrat party. Among them, how many postal points are in the Hawaii state?
SELECT CAST(SUM(CASE WHEN T1.party = 'Democrat' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*), SUM(CASE WHEN T1.state = 'Hawaii' THEN 1 ELSE 0 END) FROM congress AS T1 INNER JOIN zip_congress AS T2 ON T1.cognress_rep_id = T2.district
DIVIDE(COUNT(party = 'Democrat'), COUNT(congress_rep_id)) as percentage; postal points refer to zip_code; state = 'Hawaii';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
What is the name of the root beer brand that has the longest history?
SELECT BrandName FROM rootbeerbrand WHERE FirstBrewedYear = ( SELECT MIN(FirstBrewedYear) FROM rootbeerbrand )
name of the root beer brand refers to BrandName; longest history refers to MIN(FirstBrewedYear);
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
How many breweries are located in North America?
SELECT COUNT(BrandID) FROM rootbeerbrand WHERE Country = 'United States'
North America refers to country = 'United States'; North America is the name of continent where country = 'United States' is located;
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Please list the names of all the root beer brands that are advertised on facebook.
SELECT BrandName FROM rootbeerbrand WHERE FacebookPage IS NOT NULL
name of the root beer brand refers to BrandName; advertised on facebook refers to FacebookPage IS not NULL;
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
What is the name of the root beer brand with the lowest unit profit available to wholesalers?
SELECT BrandName FROM rootbeerbrand ORDER BY CurrentRetailPrice - WholesaleCost LIMIT 1
name of the root beer brand refers to BrandName; lowest unit profit available to wholesalers refers to MIN(SUBTRACT(CurrentRetailPrice, WholesaleCost));
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
What is the description of the root beer brand A&W?
SELECT Description FROM rootbeerbrand WHERE BrandName = 'A&W'
A&W refers to BrandName = 'A&W';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
In which city is the brewery AJ Stephans Beverages located?
SELECT City FROM rootbeerbrand WHERE BreweryName = 'AJ Stephans Beverages'
AJ Stephans refers to BreweryName = 'AJ Stephans Beverages';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
How many transactions had Frank-Paul Santangelo made in July, 2014?
SELECT COUNT(T1.CustomerID) FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.First = 'Frank-Paul' AND T1.Last = 'Santangelo' AND STRFTIME('%Y-%m', T2.TransactionDate) = '2014-07'
in July, 2014 refers to SUBSTR(TransactionDate, 1, 4) = '2014' AND SUBSTR(TransactionDate, 6, 2) = '07';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Among the transactions made in July, 2014, how many of them were made by a male customer?
SELECT COUNT(T1.CustomerID) FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Gender = 'M' AND STRFTIME('%Y-%m', T2.TransactionDate) = '2014-07'
in July, 2014 refers to SUBSTR(TransactionDate, 1, 4) = '2014' AND SUBSTR(TransactionDate, 6, 2) = '07'; male customer refers to Gender = 'M';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Among the users that permit the company to send regular emails to them, how many of them had made a transaction with a Visa card in July, 2014?
SELECT COUNT(T1.CustomerID) FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.SubscribedToEmailList = 'TRUE' AND T2.CreditCardType = 'Visa' AND STRFTIME('%Y-%m', T2.TransactionDate) = '2014-07'
users permit the company to send regular emails to them refers to subscribedtoemaillist = 'TRUE'; Visa card refers to creditcardtype = 'Visa'; in July, 2014 refers to SUBSTR(TransactionDate, 1, 4) = '2014' AND SUBSTR(TransactionDate, 6, 2) = '07';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
What is the full name of the customer that had made the most transactions in August, 2014?
SELECT T1.First, T1.Last FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE STRFTIME('%Y-%m', T2.TransactionDate) = '2014-08' GROUP BY T1.CustomerID ORDER BY COUNT(T2.CustomerID) DESC LIMIT 1
full name = First, Last; made the most transactions refers to MAX(COUNT(TransactionID)); in August, 2014 refers to SUBSTR(TransactionDate, 1, 4) = '2014' AND SUBSTR(TransactionDate, 6, 2) = '08';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Please list the brands of all the root beer that Frank-Paul Santangelo had purchased on 2014/7/7.
SELECT DISTINCT T4.BrandName FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeer AS T3 ON T2.RootBeerID = T3.RootBeerID INNER JOIN rootbeerbrand AS T4 ON T3.BrandID = T4.BrandID WHERE T1.First = 'Frank-Paul' AND T1.Last = 'Santangelo' AND T2.TransactionDate = '2014-0...
brands of the root beer refers to BrandName; purchased on 2014/7/7 refers to transactiondate = '2014-07-07';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Of the 4 root beers that Frank-Paul Santangelo purchased on 2014/7/7, how many of them were in cans?
SELECT COUNT(T1.CustomerID) FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeer AS T3 ON T2.RootBeerID = T3.RootBeerID WHERE T1.First = 'Frank-Paul' AND T1.Last = 'Santangelo' AND T2.TransactionDate = '2014-07-07' AND T3.ContainerType = 'Can'
on 2014/7/7 refers to transactiondate = '2014-07-07'; in cans refers to containertype = 'Can';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
How many root beers of the Bulldog were purchased in August, 2014?
SELECT COUNT(T1.BrandID) FROM rootbeer AS T1 INNER JOIN `transaction` AS T2 ON T1.RootBeerID = T2.RootBeerID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID WHERE T2.TransactionDate LIKE '2014-08%' AND T3.BrandName = 'Bulldog'
Bulldog refers to BrandName = 'Bulldog'; purchased in August, 2014 refers to SUBSTR(TransactionDate, 1, 4) = '2014' AND SUBSTR(TransactionDate, 6, 2) = '08';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Please list the full names of the customers who have purchased at least one root beer produced by AJ Stephans Beverages.
SELECT T1.First, T1.Last FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeer AS T3 ON T2.RootBeerID = T3.RootBeerID INNER JOIN rootbeerbrand AS T4 ON T3.BrandID = T4.BrandID WHERE T4.BreweryName = 'AJ Stephans Beverages'
full name = First, Last; customers who have purchased at least one root beer refers to CustomerID > = 1; produced by AJ Stephans Beverages refers to BreweryName = 'AJ Stephans Beverages';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Among the root beer brands that do not advertise on Twitter, how many of them have root beers sold in August, 2014?
SELECT COUNT(T1.BrandID) FROM rootbeer AS T1 INNER JOIN `transaction` AS T2 ON T1.RootBeerID = T2.RootBeerID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID WHERE T2.TransactionDate LIKE '2014-08%' AND T3.Twitter IS NULL
do not advertise on Twitter refers to twitter IS NULL; in August, 2014 refers to SUBSTR(TransactionDate, 1, 4) = '2014' AND SUBSTR(TransactionDate, 6, 2) = '08';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
What is the number of the credit card that Frank-Paul Santangelo used to purchase root beers on 2014/7/7?
SELECT DISTINCT T2.CreditCardNumber FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.First = 'Frank-Paul' AND T1.Last = 'Santangelo' AND T2.TransactionDate = '2014-07-07'
number of the credit card refers to CreditCardNumber; on 2014/7/7 refers to TransactionDate = '2014-07-07';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Among all the root beers purchased by Frank-Paul Santangelo, how many of them were non-sweetened?
SELECT COUNT(T1.CustomerID) FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeer AS T3 ON T2.RootBeerID = T3.RootBeerID INNER JOIN rootbeerbrand AS T4 ON T3.BrandID = T4.BrandID WHERE T1.First = 'Frank-Paul' AND T1.Last = 'Santangelo' AND T4.ArtificialSweetener = 'FAL...
non-sweetened refers to honey = 'FALSE' AND artificialsweetener = 'FALSE';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Please list the dates on which a male customer has purchased more than 3 root beers.
SELECT T2.TransactionDate FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Gender = 'M' GROUP BY T2.TransactionDate HAVING COUNT(T2.CustomerID) > 3
dates of purchase refers to TransactionDate; male customer refers to Gender = 'M'; purchased more than 3 root beers refers to COUNT(CustomerID) > 3;
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
What is the average number of root beers of the brand A&W sold in a day in August, 2014?
SELECT CAST(COUNT(T1.BrandID) AS REAL) / 31 FROM rootbeer AS T1 INNER JOIN `transaction` AS T2 ON T1.RootBeerID = T2.RootBeerID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID WHERE T2.TransactionDate LIKE '2014-08%' AND T3.BrandName = 'A&W'
average = DIVIDE(SUM(COUNT(RootBeerID WHERE BrandName = 'A&W' AND SUBSTR(TransactionDate, 1, 4) = '2014' AND SUBSTR(TransactionDate, 6, 2) = '08')), 31); A&W refers to BrandName = 'A&W'; in August, 2014 refers to SUBSTR(TransactionDate, 1, 4) = '2014' AND SUBSTR(TransactionDate, 6, 2) = '08';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Among all the root beers sold in 2014, what is the percentage of the root beers produced by the brewery AJ Stephans Beverages?
SELECT CAST(COUNT(CASE WHEN T3.BreweryName = 'AJ Stephans Beverages' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.BrandID) FROM rootbeer AS T1 INNER JOIN `transaction` AS T2 ON T1.RootBeerID = T2.RootBeerID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID WHERE T2.TransactionDate LIKE '2014%'
sold in 2014 refers to SUBSTR(TransactionDate, 1, 4) = '2014'; percentage = DIVIDE(MULTIPLY(SUM(BreweryName = 'AJ Stephans Beverages'), 1.0), COUNT(RootBeerID)) WHERE SUBSTR(TransactionDate, 1, 4) = '2014'; AJ Stephans Beverages refers to BreweryName = 'AJ Stephans Beverages';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Tell the number of reviews given by James House.
SELECT COUNT(T2.CustomerID) FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.First = 'James' AND T1.Last = 'House'
FALSE;
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Show the credit card number of Lisa Ling.
SELECT DISTINCT T2.CreditCardNumber FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.First = 'Lisa' AND T1.Last = 'Ling'
FALSE;
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
State the coordinate of Sac State American River Courtyard.
SELECT T2.Latitude, T2.Longitude FROM location AS T1 INNER JOIN geolocation AS T2 ON T1.LocationID = T2.LocationID WHERE T1.LocationName = 'Sac State American River Courtyard'
coordinate = Latitude, Longitude; Sac State American River Courtyard refers to LocationName = 'Sac State American River Courtyard';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Provide the name of the location where transaction no.100885 happened.
SELECT T2.LocationName FROM `transaction` AS T1 INNER JOIN location AS T2 ON T1.LocationID = T2.LocationID WHERE T1.TransactionID = 100885
name of the location refers to LocationName; transaction no. refers to TransactionID; TransactionID = 100885;
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Which city does the customer who finished transaction no.103545 live in?
SELECT T1.City FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.TransactionID = 103545
transaction no. refers to TransactionID; TransactionID = 103545;
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
What is the phone number of the customer who owns the credit card of number 6011179359005380?
SELECT DISTINCT T1.PhoneNumber FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.CreditCardNumber = 6011179359005382
FALSE;
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Which customer has the most reviews? State the full name.
SELECT T1.First, T1.Last FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID GROUP BY T1.CustomerID ORDER BY COUNT(T2.CustomerID) DESC LIMIT 1
customer that has the most reviews refers to MAX(COUNT(CustomerID)); full name = First, Last;
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
For the customer who leaves the review content of "Tastes like Australia.", when was his/her first purchase date?
SELECT T1.FirstPurchaseDate FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.Review = 'Tastes like Australia.'
review content of "Tastes like Australia." refers to Review = 'Tastes like Australia.';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
When did Natalie Dorris buy her first root beer?
SELECT T2.TransactionDate FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.First = 'Natalie' AND T1.Last = 'Dorris' ORDER BY T2.TransactionDate LIMIT 1
when a customer bought their first root beer refers to FirstPurchaseDate;
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
For the root beer brand with the most 5 star ratings, what is the name of the brewery?
SELECT T1.BreweryName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.StarRating = 5 GROUP BY T1.BrandID ORDER BY COUNT(T2.StarRating) DESC LIMIT 1
most 5 star ratings refers to MAX(COUNT(StarRating = 5)); name of the brewery refers to BreweryName;
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
For the customer who gave a 3 star rating to Frostie brand on 2014/4/24, did the user permit the company to send regular emails to him/her?
SELECT CASE WHEN T1.SubscribedToEmailList LIKE 'TRUE' THEN 'YES' ELSE 'NO' END AS result FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeerbrand AS T3 ON T2.BrandID = T3.BrandID WHERE T2.StarRating = 3 AND T3.BrandName = 'Frostie' AND T2.ReviewDate = '2014-04-24'
3 star rating refers to StarRating = 3; Frostie refers to  BrandName = 'Frostie'; if SubscribedToEmailList = 'TRUE', it means the user permit the company to send regular emails to him/her; if SubscribedToEmailList = FALSE', it means the user did not permit the company to send regular emails to him/her; rating on 2014/4...
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
For the root beer brand which got the review with the content of "The quintessential dessert root beer. No ice cream required.", what is the current retail price of the root beer?
SELECT T1.CurrentRetailPrice - T1.WholesaleCost AS price FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.Review = 'The quintessential dessert root beer. No ice cream required.'
review with the content of "The quintessential dessert root beer. No ice cream required." refers to Review = 'The quintessential dessert root beer. No ice cream required.';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
What is the percentage of 5 star ratings River City brand root beer get?
SELECT CAST(COUNT(CASE WHEN T2.StarRating = 5 THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T2.StarRating) FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T1.BrandName = 'River City'
percentage = MULTIPLY(DIVIDE(SUM(BrandID WHERE StarRating = 5), COUNT(BrandID) WHERE BrandName = 'River City'), 1.0); 5 star ratings refers to StarRating = 5; River City refers to BrandName = 'River City';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
What is the average number of reviews of all the root beer brands from "CA" State?
SELECT CAST(COUNT(*) AS REAL) / COUNT(DISTINCT T1.BrandID) AS avgreview FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T1.State = 'CA'
average = DIVIDE(COUNT(CustomerID), COUNT(BrandID) WHERE state = CA);
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
How many female customers permit the company to send regular emails to them?
SELECT COUNT(CustomerID) FROM customers WHERE Gender = 'F' AND SubscribedToEmailList = 'TRUE'
female refers to Gender = 'F'; customer permits the company to send regular emails to them refers to SubscribedToEmailList = 'TRUE';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
What is the name of the brand of the beer with the shortest brewed history?
SELECT BrandName FROM rootbeerbrand ORDER BY FirstBrewedYear DESC LIMIT 1
name of the brand of the beer refers to BrandName; shortest brewed history refers to MAX(FirstBrewedYear);
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
What are the full names of the first top 10 customers?
SELECT First, Last FROM customers ORDER BY FirstPurchaseDate LIMIT 10
full name = First Last; first top 10 customers refers to MIN(FirstPurchaseDate) LIMIT 10;
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
How many breweries are there in Australia?
SELECT COUNT(BreweryName) FROM rootbeerbrand WHERE Country = 'Australia'
Australia refers to Country = 'Australia';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
How many customers are named Charles in Sacramento?
SELECT COUNT(CustomerID) FROM customers WHERE First = 'Charles' AND City = 'Sacramento'
Sacramento refers to City = 'Sacramento';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
How many transactions were paid through MasterCard in 2014?
SELECT COUNT(TransactionID) FROM `transaction` WHERE CreditCardType = 'MasterCard' AND TransactionDate LIKE '2014%'
MasterCard refers to CreditCardType = 'MasterCard'; in 2014 refers to TransactionDate > = '2014-01-01' AND TransactionDate < = '2014-12-31';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Which brand of root beer did Jayne Collins give the lowest rating?
SELECT T3.BrandName FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeerbrand AS T3 ON T2.BrandID = T3.BrandID WHERE T1.First = 'Jayne' AND T1.Last = 'Collins' AND T2.StarRating = 1
brand of root beer refers to BrandName; lowest rating refers to MIN(StarRating);
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
How many sweet bottled root beers that do not contain cane sugar were purchased in 2015 through the selling company located in Sac State American River Courtyard?
SELECT COUNT(T1.BrandID) FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID INNER JOIN location AS T3 ON T1.LocationID = T3.LocationID WHERE T3.LocationName = 'Sac State American River Courtyard' AND T1.PurchaseDate LIKE '2015%' AND T2.Honey = 'TRUE' AND T2.CaneSugar = 'FALSE' AND T1.Containe...
sweet refers to Honey = 'TRUE'; bottled refers to ContainerType = 'Bottle'; do not contain cane sugar refers to CaneSugar = 'FALSE'; in 2015 refers to PurchaseDate < = '2015-12-31'; Sac State American River Courtyard refers to LocationName = 'Sac State American River Courtyard';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Which brewery does the most purchased root beer in 2016 belong to?
SELECT T2.BreweryName FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID WHERE T1.PurchaseDate BETWEEN '2016-01-01' AND '2016-12-31' GROUP BY T2.BrandID ORDER BY COUNT(T1.BrandID) DESC LIMIT 1
most purchased root beer refers to MAX(COUNT(BrandID)); in 2016 refers to PurchaseDate > = '2016-01-01' AND PurchaseDate < = '2016-12-31';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
What are the full names of the customer who gave River City a 5-star?
SELECT T1.First, T1.Last FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeerbrand AS T3 ON T2.BrandID = T3.BrandID WHERE T3.BrandName = 'River City' AND T2.StarRating = 5
full name = First, Last; River City refers to BrandName = 'River City'; 5-star refers to StarRating = 5;
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
How many root beers did Tom Hanks purchase between 2015 to 2016?
SELECT COUNT(T2.RootBeerID) FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.First = 'Tom' AND T1.Last = 'Hanks' AND T2.TransactionDate BETWEEN '2015-01-01' AND '2016-12-31'
between 2015 to 2016 refers to TransactionDate > = '2015-01-01' AND TransactionDate < '2016-12-31';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Which brand of root beer was highly rated by customers?
SELECT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.StarRating = 5
brand of root beer refers to BrandName; highly rated refers to MAX(COUNT(StarRating = 5));
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
How many Henry Weinhard's were bought by Nicholas Sparks?
SELECT COUNT(T1.CustomerID) FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeer AS T3 ON T2.RootBeerID = T3.RootBeerID INNER JOIN rootbeerbrand AS T4 ON T3.BrandID = T4.BrandID WHERE T1.First = 'Nicholas' AND T1.Last = 'Sparks' AND T4.BrandName LIKE 'Henry Weinhard%s...
Henry Weinhard's refers to BrandName = 'Henry Weinhard''s';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Among the root beer brands that do not advertise on Facebook and Twitter, which brand has the highest number of purchases?
SELECT T2.BreweryName FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID WHERE T2.FacebookPage IS NULL AND T2.Twitter IS NULL GROUP BY T2.BrandID ORDER BY COUNT(T1.BrandID) DESC LIMIT 1
do not advertise on Facebook and Twitter refers to FacebookPage IS NULL AND Twitter IS NULL; highest number of purchases refers to MAX(COUNT(BrandID));
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Between Sac State Union and Sac State American River Courtyard, which location sold the most Dog n Suds root beer?
SELECT T3.LocationName FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID INNER JOIN location AS T3 ON T1.LocationID = T3.LocationID WHERE T2.BrandName = 'Dog n Suds' AND T3.LocationName IN ('Sac State American River Courtyard', 'Sac State Union') GROUP BY T1.LocationID ORDER BY COUNT(T1.Bran...
Between Sac State Union and Sac State American River Courtyard refers to LocationName IN('Sac State American River Courtyard', 'Sac State Union'); Dog n Suds refers to BrandName = 'Dog n Suds'; sold the most root beer refers to MAX(COUNT(BrandID));
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
How many canned A&W were purchased in 2016?
SELECT COUNT(T1.BrandID) FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID WHERE T1.ContainerType = 'Can' AND T2.BrandName = 'A&W' AND T1.PurchaseDate LIKE '2016%'
canned refers to ContainerType = 'Can'; A&W refers to BrandName = 'A&W'; in 2016 refers to PurchaseDate > = '2016-01-01' AND PurchaseDate < = '2016-12-31';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
What is the precise location of Sac State Union?
SELECT T2.Latitude, T2.Longitude FROM location AS T1 INNER JOIN geolocation AS T2 ON T1.LocationID = T2.LocationID WHERE T1.LocationName = 'Sac State Union'
precise location = Latitude, Longitude; Sac State Union refers to LocationName = 'Sac State Union';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
What are the brands of the root beers that received 5-star ratings from no less than 5 customers?
SELECT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.StarRating = 5 GROUP BY T2.BrandID HAVING COUNT(T2.StarRating) >= 5
brand of the root beer refers to BrandName; 5-star ratings refers to StarRating = 5; no less than 5 customers refers to COUNT(CustomerID) > = 5;
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
List the brands of root beer produced by Dr Pepper Snapple Group and calculate their percentage of purchases between 2014 to 2016.
SELECT T1.BrandName , CAST(SUM(CASE WHEN T2.PurchaseDate >= '2014-01-01' AND T2.PurchaseDate <= '2016-12-31' THEN 1 ELSE 0 END) AS REAL) / COUNT(T2.BrandID) AS purchase FROM rootbeerbrand AS T1 INNER JOIN rootbeer AS T2 ON T1.BrandID = T2.BrandID WHERE T1.BreweryName = 'Dr Pepper Snapple Group' GROUP BY T2.BrandID
brand of root beer refers to BrandName; produced by Dr Pepper Snapple Group refers to BreweryName = 'Dr Pepper Snapple Group'; percentage of purchases = MULTIPLY(DIVIDE(SUM(BrandID WHERE PurchaseDate > = '2014-01-01' AND PurchaseDate < = '2016-12-31'), COUNT(BrandID) WHERE BreweryName = 'Dr Pepper Snapple Group'), 1.0)...
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Which brand of root beer has the lowest unit profit available to wholesalers? Indicate the ID of the customer that has the highest number of purchases of the said brand.
SELECT T3.BrandName, T2.CustomerID FROM rootbeer AS T1 INNER JOIN `transaction` AS T2 ON T1.RootBeerID = T2.RootBeerID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID GROUP BY T3.BrandID ORDER BY T3.CurrentRetailPrice - T3.WholesaleCost, COUNT(T1.BrandID) DESC LIMIT 1
brand of root beer refers to BrandName; lowest unit profit available to wholesalers refers to MIN(SUBTRACT(CurrentRetailPrice, WholesaleCost)); ID of the customer refers to CustomerID; highest number of purchases refers to MAX(COUNT(CustomerID));
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
List the full name and phone number of male customers from Fair Oaks who are subscribed to the email list.
SELECT First, Last, PhoneNumber FROM customers WHERE Gender = 'M' AND City = 'Fair Oaks' AND SubscribedToEmailList = 'TRUE'
full name = First, Last; male customers refers to Gender = 'M'; Fair Oaks refers to City = 'Fair Oaks'; subscribed to the email list refers to SubscribedToEmailList = 'TRUE';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Among the root beer purchased in 2014, what percentage were sold in cans?
SELECT CAST(COUNT(CASE WHEN ContainerType = 'Can' THEN RootBeerID ELSE NULL END) AS REAL) * 100 / COUNT(RootBeerID) FROM rootbeer WHERE PurchaseDate LIKE '2014%'
in 2014 refers to PurchaseDate > = '2014-01-01' AND PurchaseDate < = '2014-12-31'; percentage = MULTIPLY(DIVIDE(SUM(ContainerType = 'Can'), COUNT(RootBeerID) WHERE PurchaseDate > = '2014-01-01' AND PurchaseDate < = '2014-12-31'), 1.0); in cans refers to ContainerType = 'Can';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Give the name of the brands that brewed their first drink between 1996 and 2000 in the descending order of the date brewed.
SELECT BrandName FROM rootbeerbrand WHERE FirstBrewedYear BETWEEN '1996' AND '2000' ORDER BY FirstBrewedYear DESC
name of the brands refers to BrandName; between 1996 and 2000 refers to FirstBrewedYear > = 1996 AND FirstBrewedYear < = 2000;
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Find the brand Id of the root beer which has the most number of customers who gave 1-star ratings.
SELECT BrandID FROM rootbeerreview WHERE StarRating = 1 GROUP BY BrandID ORDER BY COUNT(BrandID) DESC LIMIT 1
most number of customers who gave 1-star ratings refers to MAX(COUNT(StarRating = 1)); 1-star ratings refers to StarRating = 1;
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Among the transactions, what percentage is done by using a visa card?
SELECT CAST(COUNT(CASE WHEN CreditCardType = 'Visa' THEN TransactionID ELSE NULL END) AS REAL) * 100 / COUNT(TransactionID) FROM `transaction`
visa card refers to CreditCardType = 'Visa'; percentage = MULTIPLY(DIVIDE(SUM(CreditCardType = 'Visa'), COUNT(TransactionID)), 1.0);
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
How many brands of root beers are available in cans and contain corn syrup and artificial sweeteners?
SELECT COUNT(BrandID) FROM rootbeerbrand WHERE CornSyrup = 'TRUE' AND ArtificialSweetener = 'TRUE' AND AvailableInCans = 'TRUE'
available in cans refers to AvailableInCans = 'TRUE'; contain corn syrup refers to CornSyrup = 'TRUE'; contain artificial sweeteners refers to ArtificialSweetener = 'TRUE';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Calculate the percentage of sales done at Sac State American River Courtyard.
SELECT CAST(COUNT(CASE WHEN T2.LocationName = 'Sac State American River Courtyard' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.TransactionID) FROM `transaction` AS T1 INNER JOIN location AS T2 ON T1.LocationID = T2.LocationID
percentage =   MULTIPLY(DIVIDE(SUM(LocationName = 'Sac State American River Courtyard'), COUNT(LocationID)), 1.0); Sac State American River Courtyard refers to LocationName = 'Sac State American River Courtyard';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
On average how many caffeinated root beers are sold a day?
SELECT CAST(COUNT(T2.RootBeerID) AS REAL) / COUNT(DISTINCT T2.PurchaseDate) FROM rootbeerbrand AS T1 INNER JOIN rootbeer AS T2 ON T1.BrandID = T2.BrandID INNER JOIN `transaction` AS T3 ON T2.RootBeerID = T3.RootBeerID WHERE T1.Caffeinated = 'TRUE'
average = DIVIDE(COUNT(RootBeerID WHERE Caffeinated = 'TRUE'), COUNT(PurchaseDate)); caffeinated refers to Caffeinated = 'TRUE';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Find the root beer with the most and least amount of profit per unit and list the container types in which these root beers are sold.
SELECT * FROM ( SELECT T1.BrandName, T2.ContainerType FROM rootbeerbrand AS T1 INNER JOIN rootbeer AS T2 ON T1.BrandID = T2.BrandID ORDER BY T1.CurrentRetailPrice - T1.WholesaleCost DESC LIMIT 1 ) UNION ALL SELECT * FROM ( SELECT T3.BrandName, T4.ContainerType FROM rootbeerbrand AS T3 INNER JOIN rootbeer AS T4 ON T3.Br...
most amount of profit per unit refers to MAX(SUBTRACT(CurrentRetailPrice, WholesaleCost)); least amount of profit per unit refers to MIN(SUBTRACT(CurrentRetailPrice, WholesaleCost));
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
What is the average cost of root beers purchased for more than 2 dollars and sold in bottles?
SELECT AVG(T2.PurchasePrice) FROM rootbeer AS T1 INNER JOIN `transaction` AS T2 ON T1.RootBeerID = T2.RootBeerID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID WHERE T1.ContainerType = 'Bottle' AND T2.PurchasePrice > 2
average cost = DIVIDE(SUM(PurchasePrice > 2), COUNT(RootBeerID) WHERE PurchasePrice > 2); more than 2 dollars refers to PurchasePrice > 2; in bottles refers to ContainerType = 'Bottle';
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Among the root beers sold in bottles, how many are sold at the location 38.559615, -121.42243?
SELECT COUNT(T4.BrandID) FROM `transaction` AS T1 INNER JOIN geolocation AS T2 ON T1.LocationID = T2.LocationID INNER JOIN location AS T3 ON T1.LocationID = T3.LocationID INNER JOIN rootbeer AS T4 ON T1.RootBeerID = T4.RootBeerID WHERE T2.Latitude = 38.559615 AND T2.Longitude = -121.42243 AND T4.ContainerType = 'Bottle...
in bottles refers to ContainerType = 'Bottle';  location 38.559615, -121.42243 refers to latitude = 38.559615 AND longitude = -121.42243;
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Among the customers not subscribed to the mailing list, what percentage has given three or more stars in a review?
SELECT CAST(COUNT(CASE WHEN T2.StarRating > 3 THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T2.CustomerID) FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.SubscribedToEmailList = 'FALSE'
not subscribed to the mailing list refers to SubscribedToEmailList = 'FALSE'; percentage = MULTIPLY(DIVIDE(SUM(CustomerID WHERE StarRating > 3), COUNT(CustomerID) WHERE SubscribedToEmailList = 'FALSE'), 1.0);
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
Which root beer got the most five stars in 2012? Give the brand name of this beer.
SELECT T3.BrandName FROM rootbeer AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID WHERE T2.StarRating = 5 AND strftime('%Y', T2.ReviewDate) = '2012' GROUP BY T1.BrandID ORDER BY COUNT(T2.BrandID) DESC LIMIT 1
most five stars refers to MAX(COUNT(StarRating = 5)); in 2012 refers to FirstBrewedYear = 2012;
beer_factory
CREATE TABLE customers ( CustomerID INTEGER primary key, First TEXT, Last TEXT, StreetAddress TEXT, City TEXT, State TEXT, ZipCode INTEGER, Email TEXT, Phone...
【DB_ID】 beer_factory 【Schema】 # Table: main.customers [ (CustomerID:INTEGER, Primary Key, Examples: [101811, 103508, 104939]), (First:TEXT, Examples: [Kenneth, Madeleine, Damen]), (Last:TEXT, Examples: [Walton, Jones, Wheeler]), (StreetAddress:TEXT, Examples: [6715 Commonwealth Dr, 3603 Leola Way, 6740 Branwood Way]), ...
In the female customers, how many bought root beer that contains artificial sweetener?
SELECT COUNT(T1.CustomerID) FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeer AS T3 ON T2.RootBeerID = T3.RootBeerID INNER JOIN rootbeerbrand AS T4 ON T3.BrandID = T4.BrandID WHERE T1.Gender = 'F' AND T4.ArtificialSweetener = 'TRUE'
female refers to Gender = 'F'; contains artificial sweetener refers to ArtificialSweetener = 'TRUE';