db_id stringclasses 68 values | question stringlengths 24 325 | evidence stringlengths 0 580 | SQL stringlengths 23 728 |
|---|---|---|---|
address | Which state has the most bad aliases? | the most bad aliases refer to MAX(COUNT(bad_alias)); | SELECT T2.state FROM avoid AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code GROUP BY T2.state ORDER BY COUNT(T1.bad_alias) DESC LIMIT 1 |
address | What is the difference in the number of bad alias between Aguada city and Aguadilla city? | SUBTRACT(COUNT(bad_alias where city = 'Aguada'), COUNT(bad_alias where city = 'Aguadilla')); | SELECT COUNT(CASE WHEN T2.city = 'Aguada' THEN T1.bad_alias ELSE NULL END) - COUNT(CASE WHEN T2.city = 'Aguadilla' THEN T1.bad_alias ELSE NULL END) AS DIFFERENCE FROM avoid AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code |
address | Which state has greater than 50 CBSA officers of metro type? | greater than 50 CBSA officers of metro type refers to COUNT(CBSA_type = 'Metro') > 50; | SELECT T2.state FROM CBSA AS T1 INNER JOIN zip_data AS T2 ON T1.CBSA = T2.CBSA WHERE T1.CBSA_type = 'Metro' GROUP BY T2.state HAVING COUNT(T1.CBSA_type) > 50 |
address | Provide the population of Arecibo in 2020. | population of Arecibo in 2020 refers to SUM(population_2020) where county = 'ARECIBO'; | SELECT SUM(T2.population_2020) FROM country AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.county = 'ARECIBO' |
address | Indicate the name of the country with a population greater than 10000 in 2010. | population greater than 10000 in 2010 refers to population_2010 > 10000; | 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 |
address | Calculate the percentage of households in residential areas of countries over 10000. | DIVIDE(SUM(households > 10000), SUM(households)) as percentage; | 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 |
address | Among the types of postal points in Saint Croix, what percentage of postal points is the post office? | DIVIDE(COUNT(type = 'Post Office' ), COUNT(type)) as percentage where county = 'SAINT CROIX'; | 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' |
address | Among the area code 787, list the country of the cities with a postal point type of unique postal office. | postal point type of unique postal office refers to type = 'Unique Post 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' |
address | 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 | In cities that do not implement daylight savings, what is the total number of cities? | do not implement daylight savings refers to daylight_savings = 'No'; | 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' |
address | 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 | 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 | List down the names of the cities belonging to Noble, Oklahoma. | the county of Noble is located in the state of 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' |
address | Among the listed cities, provide the area code of the city with the largest water area. | the largest water area refers to MAX(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 ) |
address | Provide the alias of the city with the highest population in year 2020. | the highest population in year 2020 refers to MAX(population_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 ) |
address | What is the elevation of the city belonging to Hampden, Massachusetts? | the county of Hampden is located in the state of 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 |
address | List the area code of the city with the highest Hispanic population. | the highest Hispanic population refers to MAX(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 ) |
address | Give the alias of the cities with an Asian population of 7. | Asian population of 7 refers to asian_population = 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 |
address | What is the average of the white population in the cities with area code 920? | AVG(white_population) where 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 |
address | Among the cities with alias Ponce, what is the percentage of cities with a country level FIPS code of less than 20? | DIVIDE(COUNT(county_fips < 20), COUNT(county_fips)) as percentage where alias = 'Ponce'; | 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' |
address | List down the country of the cities with a population greater than 97% of the average population of all countries in 2020. | population_2020 > MULTIPLY(0.97, AVG(population_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 ) |
address | Count the number of postal points in the district represented by Kirkpatrick Ann. | postal points refer to zip_code; | 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' |
address | Provide the zip codes and coordinates of the postal points under 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'; | 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' |
address | Provide the zip codes, cities, and locations of the postal points that have Shared Reshipper as a bad alias. | latitude and longitude coordinates can be used to identify the location; | 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' |
address | Who are the congress representatives of the postal points in Garfield? | Who are the congress representatives refer to first_name, last_name; Garfield is the city; | 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' |
address | Count the number of postal points under 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'; | 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' |
address | How many postal points are there under the congress representative in Puerto Rico? | postal points refer to zip_code; Puerto Rico refers to state = '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' |
address | Describe the number of postal points and the countries in West Virginia. | postal points refer to zip_code; West Virginia is the name of the state, in which name = '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' |
address | Provide the zip codes and area codes of the postal points with the community post office type at the elevation above 6000. | community post office type refers to type = 'Community Post Office'; elevation above 6000 refers to elevation > 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 |
address | How many postal points are there under the congress representative from the House of Representatives in Mississippi? | postal points refer to zip_code; Mississippi is the name of the state, in which name = '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' |
address | Provide the congress representatives' IDs of the postal points in East Springfield. | congress representatives' IDs refer to CID; East Springfield is the city; | 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' |
address | Who is the CBSA officer of the post point in the area with the highest number of employees? | CBSA officer refers to CBSA_name; the highest number of employees refers to MAX(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 ) |
address | How many postal points with unique post office types are there in Ohio? | 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'; | 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' |
address | Calculate the average number of beneficiaries per postal point in Guam. | DIVIDE(SUM(total_beneficiaries), COUNT(zip_code)) where name = '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' |
address | Calculate the percentage of congress representatives from the Democrat party. Among them, how many postal points are in the Hawaii state? | DIVIDE(COUNT(party = 'Democrat'), COUNT(congress_rep_id)) as percentage; postal points refer to zip_code; state = 'Hawaii'; | 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 |
beer_factory | What is the name of the root beer brand that has the longest history? | name of the root beer brand refers to BrandName; longest history refers to MIN(FirstBrewedYear); | SELECT BrandName FROM rootbeerbrand WHERE FirstBrewedYear = ( SELECT MIN(FirstBrewedYear) FROM rootbeerbrand ) |
beer_factory | How many breweries are located in North America? | North America refers to country = 'United States'; North America is the name of continent where country = 'United States' is located; | SELECT COUNT(BrandID) FROM rootbeerbrand WHERE Country = 'United States' |
beer_factory | Please list the names of all the root beer brands that are advertised on facebook. | name of the root beer brand refers to BrandName; advertised on facebook refers to FacebookPage IS not NULL; | SELECT BrandName FROM rootbeerbrand WHERE FacebookPage IS NOT NULL |
beer_factory | What is the name of the root beer brand with the lowest unit profit available to wholesalers? | name of the root beer brand refers to BrandName; lowest unit profit available to wholesalers refers to MIN(SUBTRACT(CurrentRetailPrice, WholesaleCost)); | SELECT BrandName FROM rootbeerbrand ORDER BY CurrentRetailPrice - WholesaleCost LIMIT 1 |
beer_factory | What is the description of the root beer brand A&W? | A&W refers to BrandName = 'A&W'; | SELECT Description FROM rootbeerbrand WHERE BrandName = 'A&W' |
beer_factory | In which city is the brewery AJ Stephans Beverages located? | AJ Stephans refers to BreweryName = 'AJ Stephans Beverages'; | SELECT City FROM rootbeerbrand WHERE BreweryName = 'AJ Stephans Beverages' |
beer_factory | Tell the number of reviews given by James House. | FALSE; | 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' |
beer_factory | State the coordinate of Sac State American River Courtyard. | coordinate = Latitude, Longitude; Sac State American River Courtyard refers to LocationName = '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' |
beer_factory | Which customer has the most reviews? State the full name. | customer that has the most reviews refers to MAX(COUNT(CustomerID)); full name = First, Last; | 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 |
beer_factory | For the customer who leaves the review content of "Tastes like Australia.", when was his/her first purchase date? | review content of "Tastes like Australia." refers to Review = 'Tastes like Australia.'; | SELECT T1.FirstPurchaseDate FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.Review = 'Tastes like Australia.' |
beer_factory | For the root beer brand with the most 5 star ratings, what is the name of the brewery? | most 5 star ratings refers to MAX(COUNT(StarRating = 5)); name of the brewery refers to BreweryName; | 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 |
beer_factory | 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? | 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/24 refers to ReviewDate = '2014-04-24'; | 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' |
beer_factory | 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? | 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.'; | 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.' |
beer_factory | What is the percentage of 5 star ratings River City brand root beer get? | 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'; | 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' |
beer_factory | What is the average number of reviews of all the root beer brands from "CA" State? | average = DIVIDE(COUNT(CustomerID), COUNT(BrandID) WHERE state = CA);
| 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' |
beer_factory | How many female customers permit the company to send regular emails to them? | female refers to Gender = 'F'; customer permits the company to send regular emails to them refers to SubscribedToEmailList = 'TRUE'; | SELECT COUNT(CustomerID) FROM customers WHERE Gender = 'F' AND SubscribedToEmailList = 'TRUE' |
beer_factory | What is the name of the brand of the beer with the shortest brewed history? | name of the brand of the beer refers to BrandName; shortest brewed history refers to MAX(FirstBrewedYear); | SELECT BrandName FROM rootbeerbrand ORDER BY FirstBrewedYear DESC LIMIT 1 |
beer_factory | What are the full names of the first top 10 customers? | full name = First Last; first top 10 customers refers to MIN(FirstPurchaseDate) LIMIT 10; | SELECT First, Last FROM customers ORDER BY FirstPurchaseDate LIMIT 10 |
beer_factory | How many breweries are there in Australia? | Australia refers to Country = 'Australia'; | SELECT COUNT(BreweryName) FROM rootbeerbrand WHERE Country = 'Australia' |
beer_factory | How many customers are named Charles in Sacramento? | Sacramento refers to City = 'Sacramento'; | SELECT COUNT(CustomerID) FROM customers WHERE First = 'Charles' AND City = 'Sacramento' |
beer_factory | Which brand of root beer did Jayne Collins give the lowest rating? | brand of root beer refers to BrandName; lowest rating refers to MIN(StarRating); | 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 |
beer_factory | Which brewery does the most purchased root beer in 2016 belong to? | most purchased root beer refers to MAX(COUNT(BrandID)); in 2016 refers to PurchaseDate > = '2016-01-01' AND PurchaseDate < = '2016-12-31'; | 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 |
beer_factory | What are the full names of the customer who gave River City a 5-star? | full name = First, Last; River City refers to BrandName = 'River City'; 5-star refers to StarRating = 5; | 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 |
beer_factory | Which brand of root beer was highly rated by customers? | brand of root beer refers to BrandName; highly rated refers to MAX(COUNT(StarRating = 5)); | SELECT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.StarRating = 5 |
beer_factory | Among the root beer brands that do not advertise on Facebook and Twitter, which brand has the highest number of purchases? | 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)); | 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 |
beer_factory | What is the precise location of Sac State Union? | precise location = Latitude, Longitude; Sac State Union refers to LocationName = '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' |
beer_factory | List the full name and phone number of male customers from Fair Oaks who are subscribed to the email list. | 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'; | SELECT First, Last, PhoneNumber FROM customers WHERE Gender = 'M' AND City = 'Fair Oaks' AND SubscribedToEmailList = 'TRUE' |
beer_factory | Give the name of the brands that brewed their first drink between 1996 and 2000 in the descending order of the date brewed. | name of the brands refers to BrandName; between 1996 and 2000 refers to FirstBrewedYear > = 1996 AND FirstBrewedYear < = 2000; | SELECT BrandName FROM rootbeerbrand WHERE FirstBrewedYear BETWEEN '1996' AND '2000' ORDER BY FirstBrewedYear DESC |
beer_factory | Find the brand Id of the root beer which has the most number of customers who gave 1-star ratings. | most number of customers who gave 1-star ratings refers to MAX(COUNT(StarRating = 1)); 1-star ratings refers to StarRating = 1; | SELECT BrandID FROM rootbeerreview WHERE StarRating = 1 GROUP BY BrandID ORDER BY COUNT(BrandID) DESC LIMIT 1 |
beer_factory | How many brands of root beers are available in cans and contain corn syrup and artificial sweeteners? | available in cans refers to AvailableInCans = 'TRUE'; contain corn syrup refers to CornSyrup = 'TRUE'; contain artificial sweeteners refers to ArtificialSweetener = 'TRUE'; | SELECT COUNT(BrandID) FROM rootbeerbrand WHERE CornSyrup = 'TRUE' AND ArtificialSweetener = 'TRUE' AND AvailableInCans = 'TRUE' |
beer_factory | 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. | most amount of profit per unit refers to MAX(SUBTRACT(CurrentRetailPrice, WholesaleCost)); least amount of profit per unit refers to MIN(SUBTRACT(CurrentRetailPrice, WholesaleCost)); | 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.BrandID = T4.BrandID ORDER BY T3.CurrentRetailPrice - T3.WholesaleCost ASC LIMIT 1 ) |
beer_factory | Among the customers not subscribed to the mailing list, what percentage has given three or more stars in a review? | 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); | 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' |
beer_factory | In the reviews of September 2014. Which brand of beers obtained the highest star ratings? | September 2014 refers to ReviewDate LIKE '2014-09%'; brand of beers refers to BrandName; highest star ratings refers to MAX(StarRating); | SELECT DISTINCT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.StarRating = 5 AND T2.ReviewDate BETWEEN '2014-09-01' AND '2014-09-30' |
beer_factory | From which cities are the customers who gave 5 stars in their reviews in November 2012? | 5 stars refers to StarRating = 5; in November 2012 refers to ReviewDate LIKE '2012-11%'; | SELECT DISTINCT T1.City FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.StarRating = 5 AND T2.ReviewDate BETWEEN '2012-11-01' AND '2012-11-30' |
beer_factory | What brands of beer has Peg Winchester consumed? | brands of beer refers to BrandName; | 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 = 'Peg' AND T1.Last = 'Winchester' |
beer_factory | What brand of beer has been the worst rated most times? | brand of beer refers to BrandName; worst rated most times refers to MAX(COUNT(StarRating = 1)); | SELECT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T2.BrandID = T1.BrandID WHERE T2.StarRating = 1 GROUP BY T1.BrandName ORDER BY COUNT(T1.BrandName) DESC LIMIT 1 |
beer_factory | What is the name of all the customers who have ever given a 5-star review? | name of the customer = First, Last; 5-star review refers to StarRating = 5; | SELECT T1.First, T1.Last FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.StarRating = 5 |
beer_factory | At what latitude is the Thomas Kemper brand beer consumed the most? | Thomas Kemper refers to BrandName = 'Thomas Kemper'; latitude the beer is consumed the most refers to MAX(COUNT(Latitude)); | SELECT T3.Latitude FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID INNER JOIN geolocation AS T3 ON T1.LocationID = T3.LocationID WHERE T2.BrandName = 'Thomas Kemper' GROUP BY T3.Latitude ORDER BY COUNT(T1.BrandID) DESC LIMIT 1 |
beer_factory | What star rating is the most common for beers containing corn syrup? | most common refers to MAX(COUNT(StarRating)); containing corn syrup refers to CornSyrup = 'TRUE'; | SELECT T2.StarRating FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T1.CornSyrup = 'TRUE' GROUP BY T2.StarRating ORDER BY COUNT(T2.StarRating) DESC LIMIT 1 |
beer_factory | What is the precise location of zip code 95819? | precise location = Latitude, Longitude; | SELECT T2.Latitude, T2.Longitude FROM location AS T1 INNER JOIN geolocation AS T2 ON T1.LocationID = T2.LocationID WHERE T1.ZipCode = 95819 |
beer_factory | What brands of beers are manufactured at coordinates 38,566,129, -121,426,432? | coordinates 38,566,129, -121,426,432 refers to Latitude = 38.566129 AND Longitude = -121.426432; | SELECT DISTINCT T2.BrandName FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID INNER JOIN geolocation AS T3 ON T1.LocationID = T3.LocationID WHERE T3.Latitude = '38.566129' AND T3.Longitude = '-121.426432' |
beer_factory | What is the average unit profit for wholesalers of canned beers? | average unit profit = DIVIDE(SUM(SUBTRACT(CurrentRetailPrice, WholesaleCost)), COUNT(ContainerType = 'Can')); canned beers refers to ContainerType = 'Can'; | SELECT AVG(T2.CurrentRetailPrice - T2.WholesaleCost) FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID WHERE T1.ContainerType = 'Can' |
beer_factory | List the brand IDs of the beers whose star rating is more than 3. | star rating is more than 3 refers to StarRating > 3; | SELECT BrandID FROM rootbeerreview WHERE StarRating > 3 |
beer_factory | How many brands of bottle root beer were purchased between 4/3/2015 and 10/26/2015? | bottle root beer refers to ContainerType = 'Bottle'; purchased between 4/3/2015 and 10/26/2015 refers to PurchaseDate BETWEEN '2015-04-23' AND '2015-10-26'; | SELECT COUNT(BrandID) FROM rootbeer WHERE ContainerType = 'Bottle' AND PurchaseDate BETWEEN '2015-04-03' AND '2015-10-26' |
beer_factory | What is the full name of the customer who gave a 5-star rating and commented "The quintessential dessert root beer. No ice cream required" on his review? | full name = First, Last; 5-star rating refers to StarRating = 5; commented "The quintessential dessert root beer. No ice cream required" refers to Review = 'The quintessential dessert root beer. No ice cream required.'; | SELECT T1.First, T1.Last FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.StarRating = 5 AND T2.Review = 'The quintessential dessert root beer. No ice cream required.' |
beer_factory | Tally the email addresses and phone numbers of customers from Sacramento who gave a star rating of more than 3 in 2014. | email addresses refers to Email; Sacramento refers to City = 'Sacramento'; star rating of more than 3 refers to StarRating > 3; in 2014 refers to ReviewDate LIKE '2014%'; | SELECT DISTINCT T1.Email, T1.PhoneNumber FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.StarRating > 3 AND T1.City = 'Sacramento' AND T2.ReviewDate BETWEEN '2014-01-01' AND '2014-12-31' |
beer_factory | How many female mailing list subscribers from Sacramento gave a 4-star rating between 1/3/2016 and 10/26/2016? | female refers to Gender = 'F'; mailing list subscribers refers to SubscribedToEmailList = 'TRUE'; Elk Grove refers to City = 'Sacramento'; 4-star rating refers to StarRating = 4; between 1/3/2016 and 10/26/2016 refers to ReviewDate BETWEEN '2016-01-03' AND '2016-10-26'; | SELECT COUNT(T1.CustomerID) FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.StarRating = 4 AND T1.City = 'Sacramento' AND T1.Gender = 'F' AND T1.SubscribedToEmailList = 'TRUE' AND T2.ReviewDate BETWEEN '2013-01-03' AND '2013-10-26' |
beer_factory | Give me the brewery and brand names of canned root beer that were purchased before 6/6/2015. | canned root beer refers to ContainerType = 'Can'; purchased before 6/6/2015 refers to PurchaseDate < '2015-06-06'; | SELECT DISTINCT T2.BreweryName, T2.BrandName FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID WHERE T1.PurchaseDate < '2015-06-06' AND T1.ContainerType = 'Can' |
beer_factory | What is the average star rating given by female customers to brand ID 10018 from 1/25/2015 to 3/10/2015? | average star rating = AVG(StarRating); female customers refers to Gender = 'F; from 1/25/2015 to 3/10/2015 refers to ReviewDate BETWEEN '2015-01-25' AND '2015-03-10'; | SELECT AVG(T2.StarRating) FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.BrandID = 10018 AND T1.Gender = 'F' AND T2.ReviewDate BETWEEN '2013-01-25' AND '2015-03-10' |
beer_factory | What is the brand name of the root beer that gained a 1-star rating from customer ID 331115 while saying, "Yuk, more like licorice soda"? | 1-star rating refers to StarRating = 1; saying, "Yuk, more like licorice soda" refers to Review = 'Yuk, more like licorice soda.'; | SELECT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.CustomerID = 331115 AND T2.Review = 'Yuk, more like licorice soda.' AND T2.StarRating = 1 |
beer_factory | What is the precise coordinate of Sac State Union? | precise coordinate = Latitude, Longitude; Sac State Union refers to LocationName = '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' |
beer_factory | What did the customer say in his or her review of Bulldog root beer on 7/26/2013? | Bulldog refers to BrandName = 'Bulldog'; on 7/26/2013 refers to ReviewDate = '2013-07-26'; | SELECT T2.Review FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T1.BrandName = 'Bulldog' AND T2.ReviewDate = '2013-07-26' |
beer_factory | List down the brand names of root beer that gained a 5-star rating from a customer's review in 2013. Calculate the unit profit available to wholesalers for each brand. | 5-star rating refers to StarRating = 5; in 2013 refers to ReviewDate LIKE '2013%'; unit profit available to wholesalers = SUBTRACT(CurrentRetailPrice, WholesaleCost); | SELECT T1.BrandName, T1.CurrentRetailPrice - T1.WholesaleCost AS result FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.StarRating = 5 AND T2.ReviewDate BETWEEN '2013-01-01' AND '2013-12-31' |
beer_factory | List out the root beer ID for the brand Bulldog, Bundaberg, Dad's, Dog n Suds and Virgil's. | Bulldog, Bundaberg, Dad's, Dog n Suds and Virgil's refers to BrandName IN('Bulldog', 'Bundaberg', 'Dad''s', 'Dog n Suds', 'Virgil''s'); | SELECT T1.RootBeerID FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T2.BrandID = T1.BrandID WHERE T2.BrandName IN ('Bulldog', 'Bundaberg', 'Dad''s', 'Dog n Suds', 'Virgil''s') |
beer_factory | What is the average review given by a subscriber? | average review = AVG(StarRating); subscriber refers to SubscribedToEmailList = 'TRUE'; | SELECT AVG(T2.StarRating) FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.SubscribedToEmailList = 'TRUE' |
beer_factory | What is the amount difference between the bottles of root beer sold from Louisiana and Missouri? | difference = SUBTRACT(COUNT(ContainerType = 'Bottle' WHERE State = 'LA'), COUNT(ContainerType = 'Bottle' State = 'MO')); bottles refers to ContainerType = 'Bottle'; Louisiana refers to State = 'LA'; Missouri refers to State = 'MO'; | SELECT ( SELECT COUNT(T1.BrandID) FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID WHERE T2.State = 'LA' AND T1.ContainerType = 'Bottle' ) - ( SELECT COUNT(T3.BrandID) FROM rootbeer AS T3 INNER JOIN rootbeerbrand AS T4 ON T3.BrandID = T4.BrandID WHERE T4.State = 'MO' AND T3.ContainerType = 'Bottle' ) AS DIFFERENCE |
beer_factory | Which of the root beer brand have the lowest purchase? | root beer brand refers to BrandName; lowest purchase refers to MIN(COUNT(BrandID)); | SELECT T2.BrandName FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID GROUP BY T2.BrandID ORDER BY COUNT(T1.BrandID) LIMIT 1 |
beer_factory | Please name all of the cities in California. | California refers to State = 'CA'; | SELECT DISTINCT City FROM customers WHERE State = 'CA' |
beer_factory | What is the percentage of female customers who subscribed to the email list? | percentage = MULTIPLY(DIVIDE(COUNT(CustomerID WHERE Gender = 'F'), COUNT(CustomerID) WHERE SubscribedToEmailList = 'TRUE'), 1.0); female refers to Gender = 'F'; subscribed to the email list refers to SubscribedToEmailList = 'TRUE'; | SELECT CAST(COUNT(CASE WHEN Gender = 'F' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(SubscribedToEmailList) FROM customers WHERE SubscribedToEmailList = 'TRUE' |
beer_factory | How many stars did Urijah Faber rate for Frostie? | stars refers to StarRating; Frostie refers to BrandName = 'Frostie'; | SELECT T2.StarRating 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 = 'Urijah' AND T1.Last = 'Faber' AND T3.BrandName = 'Frostie' |
beer_factory | Which brand has the lowest star rating with a "Too spicy!" review? | lowest star rating refers to MIN(StarRating); "Too spicy!" review refers to Review = 'Too Spicy!'; | SELECT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T2.BrandID = T1.BrandID WHERE T2.StarRating = 1 AND T2.Review = 'Too Spicy!' |
beer_factory | Which location sold more bottles of beer? | location refers to LocationName; bottle of beer refers to ContainerType = 'Bottle'; location that sold more bottles of beer refers to MAX(COUNT(LocationID WHERE ContainerType = 'Bottle')); | SELECT T2.LocationName FROM rootbeer AS T1 INNER JOIN location AS T2 ON T1.LocationID = T2.LocationID WHERE T1.ContainerType = 'Bottle' GROUP BY T2.LocationID ORDER BY COUNT(T1.LocationID) DESC LIMIT 1 |
beer_factory | Please name any three root beer brands that have the highest market evaluation and acceptance. | root beer brands refers to BrandName; highest market evaluation and acceptance refers to MAX(COUNT(StarRating = 5)); | SELECT DISTINCT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.StarRating = 5 LIMIT 3 |
beer_factory | What is the precise location of the Sac State American River Courtyard? | precise location = Latitude, Longitude; Sac State American River Courtyard refers to LocationName = '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' |
sales | How many sales ids are there for customer id 80? | SELECT COUNT(SalesID) FROM Sales WHERE CustomerID = 80 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.