problem
stringlengths 121
422
| db_id
stringclasses 69
values | solution
stringlengths 23
804
|
---|---|---|
Write SQL query to solve given problem: What is the average household income in the city known as "Danzig"?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | SELECT T2.avg_income_per_household FROM avoid AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.bad_alias = 'Danzig' |
Write SQL query to solve given problem: What are the states with an above-average female population?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | SELECT DISTINCT T2.state FROM state AS T1 INNER JOIN zip_data AS T2 ON T1.abbreviation = T2.state WHERE T2.female_population > ( SELECT AVG(female_population) FROM zip_data ) |
Write SQL query to solve given problem: What percentage of households are in "Coroyell" out of its state?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | SELECT CAST(SUM(CASE WHEN T1.county = 'CORYELL' THEN T2.households ELSE 0 END) AS REAL) * 100 / SUM(T2.households) FROM country AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code |
Write SQL query to solve given problem: What is the name and the position of the CBSA officer in the city of Cabo Rojo?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | SELECT T1.CBSA_name, T1.CBSA_type FROM CBSA AS T1 INNER JOIN zip_data AS T2 ON T1.CBSA = T2.CBSA WHERE T2.city = 'Cabo Rojo' GROUP BY T1.CBSA_name, T1.CBSA_type |
Write SQL query to solve given problem: Indicate the country name of the city Las Marias.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | SELECT T1.county FROM country AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.city = 'Las Marias' |
Write SQL query to solve given problem: How many cities does congressman Pierluisi Pedro represent?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | SELECT COUNT(DISTINCT T1.city) 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 T3.first_name = 'Pierluisi' AND T3.last_name = 'Pedro' |
Write SQL query to solve given problem: Provide the names of bad aliases in the city of Aguadilla.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | SELECT T1.bad_alias FROM avoid AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.city = 'Aguadilla' |
Write SQL query to solve given problem: Indicate the name of the congressman represent in Guanica.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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 = 'Guanica' |
Write SQL query to solve given problem: Which state has the most bad aliases?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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 |
Write SQL query to solve given problem: What is the difference in the number of bad alias between Aguada city and Aguadilla city?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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 |
Write SQL query to solve given problem: Which state has greater than 50 CBSA officers of metro type?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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 |
Write SQL query to solve given problem: Provide the population of Arecibo in 2020.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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' |
Write SQL query to solve given problem: Indicate the name of the country with a population greater than 10000 in 2010.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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 |
Write SQL query to solve given problem: Name the country with the largest number of households in a residential area.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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 |
Write SQL query to solve given problem: Calculate the percentage of households in residential areas of countries over 10000.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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 |
Write SQL query to solve given problem: Among the types of postal points in Saint Croix, what percentage of postal points is the post office?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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' |
Write SQL query to solve given problem: Among the area code 787, list the country of the cities with a postal point type of unique postal office.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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' |
Write SQL query to solve given problem: What is the elevation of the city with the alias East Longmeadow?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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' |
Write SQL query to solve given problem: In cities that do not implement daylight savings, what is the total number of cities?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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' |
Write SQL query to solve given problem: Give the country and area code of the city with zip code 1116.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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 |
Write SQL query to solve given problem: Among the cities with alias St Thomas, provide the type of postal point for each city.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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' |
Write SQL query to solve given problem: List down the names of the cities belonging to Noble, Oklahoma.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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' |
Write SQL query to solve given problem: Among the listed cities, provide the area code of the city with the largest water area.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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 ) |
Write SQL query to solve given problem: Provide the alias of the city with the highest population in year 2020.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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 ) |
Write SQL query to solve given problem: What is the elevation of the city belonging to Hampden, Massachusetts?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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 |
Write SQL query to solve given problem: List the area code of the city with the highest Hispanic population.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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 ) |
Write SQL query to solve given problem: Give the alias of the cities with an Asian population of 7.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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 |
Write SQL query to solve given problem: What is the average of the white population in the cities with area code 920?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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 |
Write SQL query to solve given problem: Among the cities with alias Ponce, what is the percentage of cities with a country level FIPS code of less than 20?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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' |
Write SQL query to solve given problem: List down the country of the cities with a population greater than 97% of the average population of all countries in 2020.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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 ) |
Write SQL query to solve given problem: Count the number of postal points in the district represented by Kirkpatrick Ann.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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' |
Write SQL query to solve given problem: Provide the zip codes and coordinates of the postal points under Allentown-Bethlehem-Easton, PA-NJ.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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' |
Write SQL query to solve given problem: Provide the zip codes, cities, and locations of the postal points that have Shared Reshipper as a bad alias.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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' |
Write SQL query to solve given problem: Who are the congress representatives of the postal points in Garfield?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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' |
Write SQL query to solve given problem: Count the number of postal points under New York-Newark-Jersey City, NY-NJ-PA.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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' |
Write SQL query to solve given problem: How many postal points are there under the congress representative in Puerto Rico?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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' |
Write SQL query to solve given problem: Describe the number of postal points and the countries in West Virginia.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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' |
Write SQL query to solve given problem: Provide the zip codes and area codes of the postal points with the community post office type at the elevation above 6000.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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 |
Write SQL query to solve given problem: How many postal points are there under the congress representative from the House of Representatives in Mississippi?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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' |
Write SQL query to solve given problem: Provide the congress representatives' IDs of the postal points in East Springfield.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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' |
Write SQL query to solve given problem: Who is the CBSA officer of the post point in the area with the highest number of employees?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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 ) |
Write SQL query to solve given problem: How many postal points with unique post office types are there in Ohio?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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' |
Write SQL query to solve given problem: Calculate the average number of beneficiaries per postal point in Guam.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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' |
Write SQL query to solve given problem: Calculate the percentage of congress representatives from the Democrat party. Among them, how many postal points are in the Hawaii state?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | address | 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 |
Write SQL query to solve given problem: What is the name of the root beer brand that has the longest history?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | SELECT BrandName FROM rootbeerbrand WHERE FirstBrewedYear = ( SELECT MIN(FirstBrewedYear) FROM rootbeerbrand ) |
Write SQL query to solve given problem: How many breweries are located in North America?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | SELECT COUNT(BrandID) FROM rootbeerbrand WHERE Country = 'United States' |
Write SQL query to solve given problem: Please list the names of all the root beer brands that are advertised on facebook.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | SELECT BrandName FROM rootbeerbrand WHERE FacebookPage IS NOT NULL |
Write SQL query to solve given problem: What is the name of the root beer brand with the lowest unit profit available to wholesalers?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | SELECT BrandName FROM rootbeerbrand ORDER BY CurrentRetailPrice - WholesaleCost LIMIT 1 |
Write SQL query to solve given problem: What is the description of the root beer brand A&W?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | SELECT Description FROM rootbeerbrand WHERE BrandName = 'A&W' |
Write SQL query to solve given problem: In which city is the brewery AJ Stephans Beverages located?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | SELECT City FROM rootbeerbrand WHERE BreweryName = 'AJ Stephans Beverages' |
Write SQL query to solve given problem: How many transactions had Frank-Paul Santangelo made in July, 2014?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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' |
Write SQL query to solve given problem: Among the transactions made in July, 2014, how many of them were made by a male customer?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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' |
Write SQL query to solve given problem: 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?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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' |
Write SQL query to solve given problem: What is the full name of the customer that had made the most transactions in August, 2014?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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 |
Write SQL query to solve given problem: Please list the brands of all the root beer that Frank-Paul Santangelo had purchased on 2014/7/7.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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-07-07' |
Write SQL query to solve given problem: Of the 4 root beers that Frank-Paul Santangelo purchased on 2014/7/7, how many of them were in cans?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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' |
Write SQL query to solve given problem: How many root beers of the Bulldog were purchased in August, 2014?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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' |
Write SQL query to solve given problem: Please list the full names of the customers who have purchased at least one root beer produced by AJ Stephans Beverages.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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' |
Write SQL query to solve given problem: Among the root beer brands that do not advertise on Twitter, how many of them have root beers sold in August, 2014?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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 |
Write SQL query to solve given problem: What is the number of the credit card that Frank-Paul Santangelo used to purchase root beers on 2014/7/7?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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' |
Write SQL query to solve given problem: Among all the root beers purchased by Frank-Paul Santangelo, how many of them were non-sweetened?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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 = 'FALSE' AND T4.Honey = 'FALSE' |
Write SQL query to solve given problem: Please list the dates on which a male customer has purchased more than 3 root beers.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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 |
Write SQL query to solve given problem: What is the average number of root beers of the brand A&W sold in a day in August, 2014?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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' |
Write SQL query to solve given problem: Among all the root beers sold in 2014, what is the percentage of the root beers produced by the brewery AJ Stephans Beverages?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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%' |
Write SQL query to solve given problem: Tell the number of reviews given by James House.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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' |
Write SQL query to solve given problem: Show the credit card number of Lisa Ling.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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' |
Write SQL query to solve given problem: State the coordinate of Sac State American River Courtyard.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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' |
Write SQL query to solve given problem: Provide the name of the location where transaction no.100885 happened.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | SELECT T2.LocationName FROM `transaction` AS T1 INNER JOIN location AS T2 ON T1.LocationID = T2.LocationID WHERE T1.TransactionID = 100885 |
Write SQL query to solve given problem: Which city does the customer who finished transaction no.103545 live in?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | SELECT T1.City FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.TransactionID = 103545 |
Write SQL query to solve given problem: What is the phone number of the customer who owns the credit card of number 6011179359005380?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | SELECT DISTINCT T1.PhoneNumber FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.CreditCardNumber = 6011179359005382 |
Write SQL query to solve given problem: Which customer has the most reviews? State the full name.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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 |
Write SQL query to solve given problem: For the customer who leaves the review content of "Tastes like Australia.", when was his/her first purchase date?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | SELECT T1.FirstPurchaseDate FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.Review = 'Tastes like Australia.' |
Write SQL query to solve given problem: When did Natalie Dorris buy her first root beer?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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 |
Write SQL query to solve given problem: For the root beer brand with the most 5 star ratings, what is the name of the brewery?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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 |
Write SQL query to solve given problem: 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?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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' |
Write SQL query to solve given problem: 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?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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.' |
Write SQL query to solve given problem: What is the percentage of 5 star ratings River City brand root beer get?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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' |
Write SQL query to solve given problem: What is the average number of reviews of all the root beer brands from "CA" State?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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' |
Write SQL query to solve given problem: How many female customers permit the company to send regular emails to them?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | SELECT COUNT(CustomerID) FROM customers WHERE Gender = 'F' AND SubscribedToEmailList = 'TRUE' |
Write SQL query to solve given problem: What is the name of the brand of the beer with the shortest brewed history?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | SELECT BrandName FROM rootbeerbrand ORDER BY FirstBrewedYear DESC LIMIT 1 |
Write SQL query to solve given problem: What are the full names of the first top 10 customers?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | SELECT First, Last FROM customers ORDER BY FirstPurchaseDate LIMIT 10 |
Write SQL query to solve given problem: How many breweries are there in Australia?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | SELECT COUNT(BreweryName) FROM rootbeerbrand WHERE Country = 'Australia' |
Write SQL query to solve given problem: How many customers are named Charles in Sacramento?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | SELECT COUNT(CustomerID) FROM customers WHERE First = 'Charles' AND City = 'Sacramento' |
Write SQL query to solve given problem: How many transactions were paid through MasterCard in 2014?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | SELECT COUNT(TransactionID) FROM `transaction` WHERE CreditCardType = 'MasterCard' AND TransactionDate LIKE '2014%' |
Write SQL query to solve given problem: Which brand of root beer did Jayne Collins give the lowest rating?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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 |
Write SQL query to solve given problem: 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?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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.ContainerType = 'Bottle' |
Write SQL query to solve given problem: Which brewery does the most purchased root beer in 2016 belong to?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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 |
Write SQL query to solve given problem: What are the full names of the customer who gave River City a 5-star?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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 |
Write SQL query to solve given problem: How many root beers did Tom Hanks purchase between 2015 to 2016?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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' |
Write SQL query to solve given problem: Which brand of root beer was highly rated by customers?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | SELECT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.StarRating = 5 |
Write SQL query to solve given problem: How many Henry Weinhard's were bought by Nicholas Sparks?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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' |
Write SQL query to solve given problem: Among the root beer brands that do not advertise on Facebook and Twitter, which brand has the highest number of purchases?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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 |
Write SQL query to solve given problem: Between Sac State Union and Sac State American River Courtyard, which location sold the most Dog n Suds root beer?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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.BrandID) DESC LIMIT 1 |
Write SQL query to solve given problem: How many canned A&W were purchased in 2016?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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%' |
Write SQL query to solve given problem: What is the precise location of Sac State Union?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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' |
Write SQL query to solve given problem: What are the brands of the root beers that received 5-star ratings from no less than 5 customers?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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 |
Write SQL query to solve given problem: List the brands of root beer produced by Dr Pepper Snapple Group and calculate their percentage of purchases between 2014 to 2016.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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 |
Write SQL query to solve given problem: 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.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | 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 |
Write SQL query to solve given problem: List the full name and phone number of male customers from Fair Oaks who are subscribed to the email list.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | SELECT First, Last, PhoneNumber FROM customers WHERE Gender = 'M' AND City = 'Fair Oaks' AND SubscribedToEmailList = 'TRUE' |
Write SQL query to solve given problem: Among the root beer purchased in 2014, what percentage were sold in cans?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | beer_factory | SELECT CAST(COUNT(CASE WHEN ContainerType = 'Can' THEN RootBeerID ELSE NULL END) AS REAL) * 100 / COUNT(RootBeerID) FROM rootbeer WHERE PurchaseDate LIKE '2014%' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.