db_id
stringclasses
69 values
question
stringlengths
24
325
evidence
stringlengths
0
673
SQL
stringlengths
23
804
question_id
int64
0
9.43k
difficulty
stringclasses
1 value
beer_factory
Calculate the difference between the number of root beers sold that use cane sugar and corn syrup.
difference = SUBTRACT(SUM(CaneSugar = 'TRUE'), SUM(CornSyrup = 'TRUE')); use cane sugar refers to CaneSugar = 'TRUE'; corn syrup refers to CornSyrup = 'TRUE';
SELECT COUNT(CASE WHEN T3.CaneSugar = 'TRUE' THEN T1.BrandID ELSE NULL END) - COUNT(CASE WHEN T3.CornSyrup = 'TRUE' THEN T1.BrandID ELSE NULL END) AS DIFFERENCE FROM rootbeer AS T1 INNER JOIN `transaction` AS T2 ON T1.RootBeerID = T2.RootBeerID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID
5,300
beer_factory
Which brewery brewed the most sold root beer in 2015?
brewery refers to BreweryName; most sold root beer refers to MAX(COUNT(BrandID)); in 2015 refers to TransactionDate > = '2015-01-01' AND TransactionDate < = '2015-12-31';
SELECT T3.BreweryName 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 '2015%' GROUP BY T3.BrandID ORDER BY COUNT(T1.BrandID) DESC LIMIT 1
5,301
beer_factory
Among the male customers in Sacramento, what percentage bought Dominion root beer in 2013?
male customers refers to Gender = 'M'; Sacramento refers to City = 'Sacramento'; percentage = MULTIPLY(DIVIDE(SUM(BrandID WHERE BrandName = 'Dominion'), COUNT(BrandID) WHERE City = 'Sacramento'), 1.0); Dominion refers to BrandName = 'Dominion'; in 2013 refers to TransactionDate > = 2013-01-01 AND TransactionDate < 2014-01-01;
SELECT CAST(COUNT(CASE WHEN T4.BrandName = 'Dominion' THEN T1.CustomerID ELSE NULL END) AS REAL) * 100 / 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.City = 'Sacramento' AND T1.Gender = 'M' AND T2.TransactionDate LIKE '2014%'
5,302
beer_factory
What is the difference in the average number of sales per day of root beer brands that contain honey and that don’t contain honey.
difference in the average = SUBTRACT(DIVIDE(MULTIPLY(SUM(Honey = 'TRUE'), 1.0), COUNT(TransactionDate)), DIVIDE(MULTIPLY(SUM(Honey = 'FALSE'), 1.0), COUNT(TransactionDate))); contain honey refers to Honey = 'TRUE'; don’t contain honey refers to Honey = 'FALSE'
SELECT (CAST(SUM(CASE WHEN T1.Honey = 'TRUE' THEN 1 ELSE 0 END) AS REAL) / COUNT(DISTINCT T3.TransactionDate)) - (CAST(SUM(CASE WHEN T1.Honey <> 'TRUE' THEN 1 ELSE 0 END) AS REAL) / COUNT(DISTINCT T3.TransactionDate)) FROM rootbeerbrand AS T1 INNER JOIN rootbeer AS T2 ON T1.BrandID = T2.BrandID INNER JOIN `transaction` AS T3 ON T2.RootBeerID = T3.RootBeerID
5,303
beer_factory
Find and list the full name and email of the customers who used American Express cards in Sac State Union.
full name = First, Last; American Express cards refers to CreditCardType = 'American Express'; Sac State Union refers to LocationName = 'Sac State Union';
SELECT DISTINCT T1.First, T1.Last, T1.Email FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN location AS T3 ON T2.LocationID = T3.LocationID WHERE T3.LocationName = 'Sac State Union' AND T2.CreditCardType = 'American Express'
5,304
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'
5,305
beer_factory
What is the precise location of all paying customers with American Express?
precise location refers to Latitude, Longitude; American Express refers to CreditCardType = 'American Express';
SELECT DISTINCT T2.Latitude, T2.Longitude FROM `transaction` AS T1 INNER JOIN geolocation AS T2 ON T1.LocationID = T2.LocationID WHERE T1.CreditCardType = 'American Express'
5,306
beer_factory
How many Folsom customers prefer to pay with Visa?
Folsom refers to City = 'Folsom'; Visa refers to CreditCardType = 'Visa';
SELECT COUNT(T1.CustomerID) FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.City = 'Folsom' AND T2.CreditCardType = 'Visa'
5,307
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'
5,308
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'
5,309
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
5,310
beer_factory
What credit card is the most used in the purchase of non-alcoholic beer?
credit card that is the most used refers to MAX(COUNT(CreditCardType)); non-alcoholic beer refers to Alcoholic = 'FALSE';
SELECT T2.CreditCardType 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 T3.Alcoholic = 'FALSE' GROUP BY T2.CreditCardType ORDER BY COUNT(T2.CreditCardType) DESC LIMIT 1
5,311
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
5,312
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
5,313
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
5,314
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
5,315
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'
5,316
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'
5,317
beer_factory
What percentage of customers who paid with a Discover Credit Card gave a 3-star rating?
percentage = MULTIPLY(DIVIDE(COUNT(CustomerID WHERE StarRating = 3), COUNT(CustomerID) WHERE CreditCardType = 'Discover'), 100); Discover Credit Card refers to CreditCardType = 'Discover'; 3-star rating refers to StarRating = 3;
SELECT CAST(COUNT(CASE WHEN T1.StarRating = 3 THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.CustomerID) FROM rootbeerreview AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.CreditCardType = 'Discover'
5,318
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
5,319
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'
5,320
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.'
5,321
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'
5,322
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'
5,323
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'
5,324
beer_factory
List the brand names of bottled root beer whose first brewing year is no later than 1930.
bottled root beer refers to ContainerType = 'Bottle'; first brewing year is no later than 1930 refers to FirstBrewedYear < 1930;
SELECT T2.BrandName FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID WHERE T2.FirstBrewedYear < '1930-01-01' AND T1.ContainerType = 'Bottle' ORDER BY T2.FirstBrewedYear LIMIT 1
5,325
beer_factory
How many times did Anna Himes use her Mastercard when paying between 12/25/2014 and 5/20/2016 ?
Mastercard refers to CreditCardType = 'MasterCard'; between 12/25/2014 and 5/20/2016 refers to TransactionDate BETWEEN '2014-12-25' AND '2016-05-20';
SELECT COUNT(T2.CustomerID) FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.First = 'Anna' AND T1.Last = 'Himes' AND T2.CreditCardType = 'MasterCard' AND T2.TransactionDate BETWEEN '2014-12-25' AND '2016-05-20'
5,326
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'
5,327
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
5,328
beer_factory
Calculate the total purchases made by customers using their Visa credit cards in the Sac State American River Courtyard between 6/3/2014 and 11/27/2015.
total purchases = SUM(PurchasePrice); Visa credit card refers to CreditCardType = 'Visa'; Sac State American River Courtyard refers to LocationName = 'Sac State American River Courtyard'; between 6/3/2014 and 11/27/2015 refers to TransactionDate BETWEEN '2014-06-03' AND '2015-11-27';
SELECT SUM(T1.PurchasePrice) FROM `transaction` AS T1 INNER JOIN location AS T2 ON T1.LocationID = T2.LocationID WHERE T2.LocationName = 'Sac State American River Courtyard' AND T1.CreditCardType = 'Visa' AND T1.TransactionDate BETWEEN '2014-06-03' AND '2015-11-27'
5,329
beer_factory
How many transactions were made in Sac State Union using the American Express credit card in 2014?
Sac State Union refers to LocationName = 'Sac State Union'; American Express credit card refers to CreditCardType = 'American Express'; in 2014 refers to TransactionDate LIKE '2014%';
SELECT COUNT(T1.TransactionID) FROM `transaction` AS T1 INNER JOIN location AS T2 ON T1.LocationID = T2.LocationID WHERE T2.LocationName = 'Sac State Union' AND T1.CreditCardType = 'American Express' AND T1.TransactionDate BETWEEN '2014-01-01' AND '2014-12-31'
5,330
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'
5,331
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'
5,332
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'
5,333
beer_factory
Give me the full name of the first customer, and tell me how long ago he or she wrote his or her first review since making his or her first purchase.
full name = First, Last; how long ago = SUBTRACT(ReviewDate, FirstPurchaseDate);
SELECT T1.First, T1.Last , strftime('%J', ReviewDate) - strftime('%J', FirstPurchaseDate) AS TIMEAGO FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID LIMIT 1
5,334
beer_factory
What is the credit card type used by Kenneth Walton?
FALSE;
SELECT DISTINCT T2.CreditCardType FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.First = 'Kenneth' AND T1.Last = 'Walton'
5,335
beer_factory
What is the container type, brand name and star rating for root beer ID 10054?
FALSE;
SELECT T4.ContainerType, T3.BrandName, T1.StarRating FROM rootbeerreview AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID INNER JOIN rootbeer AS T4 ON T2.RootBeerID = T4.RootBeerID WHERE T2.RootBeerID = 100054
5,336
beer_factory
List out the root beers bought by Tim Ocel and Dawn Childress.
FALSE;
SELECT T2.RootBeerID FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T2.CustomerID = T1.CustomerID WHERE (T1.First = 'Tim' AND T1.Last = 'Ocel') OR (T1.First = 'Dawn' AND T1.Last = 'Childress')
5,337
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')
5,338
beer_factory
How many bottles of beer have been bought by Jim Breech?
bottles refers to ContainerType = 'Bottle';
SELECT COUNT(T3.ContainerType) FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T2.CustomerID = T1.CustomerID INNER JOIN rootbeer AS T3 ON T3.RootBeerID = T2.RootBeerID WHERE T3.ContainerType = 'Bottle' AND T1.First = 'Jim' AND T1.Last = 'Breech'
5,339
beer_factory
How many transactions have been made to purchase a root beer brand from California?
California refers to State = 'CA';
SELECT COUNT(T3.RootBeerID) 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.State = 'CA'
5,340
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'
5,341
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
5,342
beer_factory
What is the transaction ratio being made at Sac State American River Courtyard and Sac State Union?
transaction ratio = DIVIDE(SUM(TransactionID WHERE LocationName = 'Sac State American River Courtyard'), SUM(TransactionID WHERE LocationName = 'Sac State Union')); Sac State American River Courtyard refers to LocationName = 'Sac State American River Courtyard'; Sac State Union refers to LocationName = 'Sac State Union';
SELECT CAST(COUNT(CASE WHEN T2.LocationName = 'Sac State American River Courtyard' THEN T1.TransactionID ELSE NULL END) AS REAL) * 100 / COUNT(CASE WHEN T2.LocationName = 'Sac State Union' THEN T1.TransactionID ELSE NULL END) FROM `transaction` AS T1 INNER JOIN location AS T2 ON T1.LocationID = T2.LocationID
5,343
beer_factory
List out the name of the top 10 spenders and what credit card type are they using.
top 10 spenders refers to MAX(PurchasePrice) LIMIT 10;
SELECT T1.First, T1.Last, T2.CreditCardType FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID GROUP BY T1.CustomerID ORDER BY SUM(T2.PurchasePrice) DESC LIMIT 10
5,344
beer_factory
List out root beer brand that is not caffeinated and not containing cane sugar. What is the total amount sold for this products?
root beer brand refers to BrandName; not caffeinated refers to Caffeinated = 'FALSE'; not containing cane sugar refers to CaneSugar = 'FALSE'; total amount sold = SUM(PurchasePrice);
SELECT T1.BrandName, SUM(T3.PurchasePrice) 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.CaneSugar = 'FALSE' AND T1.Caffeinated = 'FALSE' GROUP BY T1.BrandName
5,345
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
5,346
beer_factory
What is the best seller root beer brand and what is the average star rating for this root beer?
best seller root beer refers to MAX(COUNT(BrandID)); average star rating = AVG(StarRating);
SELECT T1.BrandID, AVG(T1.StarRating) FROM rootbeerreview AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID GROUP BY T3.BrandID ORDER BY COUNT(T1.BrandID) DESC LIMIT 1
5,347
beer_factory
What is the percentage difference of River City sale compare to Frostie?
percentage difference = (DIVIDE(MULTIPLY(SUBTRACT(SUM(PurchasePrice WHERE BrandName = 'River City'), SUM(PurchasePrice WHERE BrandName = 'Frostie')), 100), SUM(PurchasePrice WHERE BrandName = 'Frostie'))); River City refers to BrandName = 'River City'; Frostie refers to BrandName = 'Frostie';
SELECT CAST((SUM(CASE WHEN T3.BrandName = 'River City' THEN T2.PurchasePrice ELSE 0 END) - SUM(CASE WHEN T3.BrandName = 'Frostie' THEN T2.PurchasePrice ELSE 0 END)) AS REAL) * 100 / SUM(CASE WHEN T3.BrandName = 'Frostie' THEN T2.PurchasePrice ELSE 0 END) FROM rootbeer AS T1 INNER JOIN `transaction` AS T2 ON T1.RootBeerID = T2.RootBeerID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID
5,348
beer_factory
Please name all of the cities in California.
California refers to State = 'CA';
SELECT DISTINCT City FROM customers WHERE State = 'CA'
5,349
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'
5,350
beer_factory
Which type of card did Dick Ruthven use to pay for all of his transactions?
type of card refers to CreditCardType;
SELECT DISTINCT T2.CreditCardType FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.First = 'Dick' AND T1.Last = 'Ruthven'
5,351
beer_factory
How many transactions were made at Sac State Union?
Sac State Union refers to LocationName = 'Sac State Union';
SELECT COUNT(T1.TransactionID) FROM `transaction` AS T1 INNER JOIN location AS T2 ON T1.LocationID = T2.LocationID WHERE T2.LocationName = 'Sac State Union'
5,352
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'
5,353
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!'
5,354
beer_factory
How many purchases were made at Sac State American River Courtyard using Master Card?
Sac State American River Courtyard refers to LocationName = 'Sac State American River Courtyard'; Master Card refers to CreditCardType = 'MasterCard';
SELECT COUNT(T1.TransactionID) FROM `transaction` AS T1 INNER JOIN location AS T2 ON T1.LocationID = T2.LocationID WHERE T2.LocationName = 'Sac State American River Courtyard' AND T1.CreditCardType = 'MasterCard'
5,355
beer_factory
Which brand in 2012 has the lowest star rating and contains cane sugar as well as honey?
brand refers to BrandName; in 2012 refers to ReviewDate LIKE '2012%'; lowest star rating refers to MIN(StarRating); contains cane sugar as well as honey refers to CaneSugar = 'TRUE' AND Honey = 'TRUE';
SELECT DISTINCT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T1.CaneSugar = 'TRUE' AND T1.Honey = 'TRUE' AND T2.StarRating = 1 AND T2.ReviewDate LIKE '2012%'
5,356
beer_factory
What is the precise location of the place where Tommy Kono made a purchase in 2014?
precise location = Latitude, Longitude; in 2014 refers to TransactionDate LIKE '2014%';
SELECT DISTINCT T1.Latitude, T1.Longitude FROM geolocation AS T1 INNER JOIN `transaction` AS T2 ON T2.LocationID = T1.LocationID INNER JOIN customers AS T3 ON T3.CustomerID = T2.CustomerID WHERE T3.First = 'Tommy' AND T3.Last = 'Kono' AND T2.TransactionDate LIKE '2014%'
5,357
beer_factory
What is the email address of the customer who made a purchase in transaction 100016?
email address refers to Email; transaction 100016 refers to TransactionID = 100016;
SELECT T1.Email FROM customers AS T1 INNER JOIN `transaction` AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.TransactionID = '100016'
5,358
beer_factory
How many transactions were made to purchase a bottle of beer using American Express?
bottle of beer refers to ContainerType = 'Bottle'; American Express refers to CreditCardType = 'American Express';
SELECT COUNT(T1.RootBeerID) FROM rootbeer AS T1 INNER JOIN `transaction` AS T2 ON T1.RootBeerID = T2.RootBeerID WHERE T1.ContainerType = 'Bottle' AND T2.CreditCardType = 'American Express'
5,359
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
5,360
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
5,361
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'
5,362
sales
How many sales ids are there for customer id 80?
SELECT COUNT(SalesID) FROM Sales WHERE CustomerID = 80
5,363
sales
Count the total quantity for sales from id 1 to 10.
sales from id 1 to 10 refers to SalesID BETWEEN 1 AND 10;
SELECT SUM(Quantity) FROM Sales WHERE SalesID BETWEEN 1 AND 10
5,364
sales
Calculate the average quantity per sales from sales id 20 to 30.
average quantity = AVG(Quantity); SalesID BETWEEN 20 AND 30;
SELECT AVG(Quantity) FROM Sales WHERE SalesID BETWEEN 20 AND 30
5,365
sales
List down the product id for products with the highest quantity.
highest quantity refers to MAX(Quantity);
SELECT DISTINCT ProductID FROM Sales WHERE Quantity = ( SELECT MAX(Quantity) FROM Sales )
5,366
sales
How many product ids have the lowest price?
lowest price refers to MIN(Price);
SELECT COUNT(DISTINCT ProductID) FROM Products WHERE Price = ( SELECT MAX(Price) FROM Products )
5,367
sales
List down product names of free gifts.
free gifts refers to Price = 0;
SELECT Name FROM Products WHERE Price = 0
5,368
sales
List down the product name for products from id 1 to 10.
products from id 1 to 10 refers to ProductID BETWEEN 1 AND 10;
SELECT Name FROM Products WHERE ProductID BETWEEN 1 AND 10
5,369
sales
What is the name of the product with the lowest quantity?
lowest quantity refers to MIN(Quantity);
SELECT T2.Name FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID ORDER BY T1.Quantity LIMIT 1
5,370
sales
How many customer ids have purchased Hex Nut 9?
Hex Nut 9' is name of product;
SELECT COUNT(T1.CustomerID) FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'Hex Nut 9'
5,371
sales
Calculate the total sales ids that were sales of Flat Washer 8.
Flat Washer 8' is name of product;
SELECT COUNT(T1.SalesID) FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'Flat Washer 8'
5,372
sales
List down all of the product names that were placed by sales person with id 10.
id refers to SalesPersonID; SalesPersonID = 10
SELECT DISTINCT T1.Name FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T2.SalesPersonID = 10
5,373
sales
List down the first name of customers who placed order for product id 1.
SELECT T1.FirstName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T2.ProductID = 1
5,374
sales
What is the last name of the customer who placed an order for sales id 178?
SELECT T1.LastName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.SalesID = 178
5,375
sales
List down product ids that were purchased by customers called Abby.
SELECT DISTINCT T1.ProductID FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.FirstName = 'Abby'
5,376
sales
Write down all of the product ids that were placed by Meander.
SELECT DISTINCT T2.ProductID FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID WHERE T1.FirstName = 'Meander'
5,377
sales
What is the last name of sales person for sales id 100?
SELECT T1.LastName FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID WHERE T2.SalesID = 100
5,378
sales
What is the first name of employee who handled sales for customer called Abigail?
SELECT DISTINCT T3.FirstName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Employees AS T3 ON T2.SalesPersonID = T3.EmployeeID WHERE T1.FirstName = 'Abigail'
5,379
sales
How many free gifts have customer with id 11782 received?
free gifts refers to Price = 0;
SELECT COUNT(T1.ProductID) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T2.CustomerID = 11782 AND T1.Price = 0
5,380
sales
What is the full name of customers who dealt with sales person with id 5?
full name = FirstName, MiddleInitial, LastName;
SELECT T1.FirstName, T1.MiddleInitial, T1.LastName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.SalesPersonID = 5
5,381
sales
List down all of the sales IDs for sales handled by sales people with first name starting with alphabet "s".
first name starting with alphabet "s" refers to FirstName LIKE 's%';
SELECT T1.SalesID FROM Sales AS T1 INNER JOIN Employees AS T2 ON T1.SalesPersonID = T2.EmployeeID WHERE SUBSTR(T2.FirstName, 1, 1) = 's'
5,382
sales
Among customers with IDs from 1 to 100, what is the highest price of products they purchased?
IDs from 1 to 100 refers to CustomerID BETWEEN 1 AND 100 ; highest price refers to MAX(Price);
SELECT T1.Price FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T2.CustomerID BETWEEN 1 AND 100 ORDER BY T1.Price DESC LIMIT 1
5,383
sales
Among customers with the last name of Valdez, who purchased the highest quantity?
highest quantity refers to MAX(Quantity);
SELECT T1.FirstName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.LastName = 'Valdez' ORDER BY T2.Quantity DESC LIMIT 1
5,384
sales
Sum up the number sales ids handled by employees called Morningstar, Heather and Dean.
SUM = ADD(SUM(SalesID WHERE FirstName = 'Morningstar'), SUM(SalesID WHERE FirstName = 'Heather'), SUM(SalesID WHERE FirstName = 'Dean'));
SELECT SUM(IIF(T2.FirstName = 'Morningstar', 1, 0)) + SUM(IIF(T2.FirstName = 'Heather', 1, 0)) + SUM(IIF(T2.FirstName = 'Dean', 1, 0)) AS num FROM Sales AS T1 INNER JOIN Employees AS T2 ON T1.SalesPersonID = T2.EmployeeID
5,385
sales
Has Alex purchased product with id 498?
WHEN ProductID = 498 AND FirstName = 'Alex' means that Alex purchased a product; WHEN ProductID = 498 AND FirstName NOT 'Alex' means Alex has not purchased a product;
SELECT IIF(T1.ProductID = 498, 'YES', 'NO') FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.FirstName = 'Alex'
5,386
sales
Calculate the total price of products purchased by Adam.
total price = SUM(MULTIPLY(Price, Quantity));
SELECT SUM(T3.Price * T2.quantity) FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T1.FirstName = 'Adam'
5,387
sales
Calculate the total price for products from id 400 to 500.
total price = SUM(MULTIPLY(Price, Quantity)); from id 400 to 500 refers to ProductID BETWEEN 400 AND 500;
SELECT SUM(T1.Price * T2.quantity) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductID BETWEEN 400 AND 500
5,388
sales
Calculate the total quantity of products with name starting with alphabet "c".
name starting with alphabet "c" refers to Name LIKE 'C%';
SELECT SUM(T2.Quantity) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE SUBSTR(T1.Name, 1, 1) = 'C'
5,389
sales
Calculate the total quantity of products purchased by customer called Adrian.
SELECT SUM(T2.Quantity) FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.FirstName = 'Adam'
5,390
sales
List the product ID of the top five products, by descending order, in terms of price.
top 5 products in terms of Price refers to MAX(Price) LIMIT 5;
SELECT ProductID FROM Products ORDER BY Price DESC LIMIT 5
5,391
sales
Among the products, how many of them are freebies?
freebies refers to Price = 0;
SELECT COUNT(ProductID) FROM Products WHERE Price = 0
5,392
sales
Write down the name of products whose sale quantity is more than 950.
quantity is more than 950 refers to Quantity > 950;
SELECT DISTINCT T1.Name FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Quantity > 950
5,393
sales
What is the full name of employee who sold 1000 units?
full name of employee = FirstName, MiddleInitial, LastName; units refers to quantity; Quantity = 100
SELECT DISTINCT T2.FirstName, T2.MiddleInitial, T2.LastName FROM Sales AS T1 INNER JOIN Employees AS T2 ON T1.SalesPersonID = T2.EmployeeID WHERE T1.Quantity = 1000
5,394
sales
Tally the product name and quantity of the first ten sales.
first ten sales refers to SalesID BETWEEN 1 AND 10;
SELECT T3.Name, T2.Quantity FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T2.SalesID BETWEEN 1 AND 10
5,395
sales
What is the total sales amount for Reflector?
total sales amount = SUM(MULTIPLY(Price, Quantity)); 'Reflector' is name of product;
SELECT SUM(T1.Price * T2.quantity) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'Reflector'
5,396
sales
What is the best selling colour for HL Mountain Frame, 42?
best selling colour refers to name of product with higher total sales; SUM(SalesID WHERE Name = 'HL Mountain Frame - Silver, 42') > SUM(Name = 'HL Mountain Frame - Black, 42') means Silver is the best selling colour, otherwise Black is the best seling colour;
SELECT IIF(SUM(IIF(T1.Name = 'HL Mountain Frame - Silver, 42', T2.SalesID, 0)) - SUM(IIF(T1.Name = 'HL Mountain Frame - Black, 42', T2.SalesID, 0)) > 0, 'Silver', 'Black') FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID
5,397
sales
What is the difference in price between HL Mountain Frame - Black, 42 and LL Mountain Frame - Black, 42?
difference = SUBTRACT((Price WHERE Name = 'HL Mountain Frame - Black, 42'), (Price WHERE Name = 'HL Mountain Frame - Black, 42'));
SELECT ( SELECT Price FROM Products WHERE Name = 'HL Mountain Frame - Black, 42' ) - ( SELECT Price FROM Products WHERE Name = 'LL Mountain Frame - Black, 42' ) AS num
5,398
sales
Calculate the total number of sales closed by Michel E. DeFrance?
SELECT COUNT(T1.SalesID) FROM Sales AS T1 INNER JOIN Employees AS T2 ON T1.SalesPersonID = T2.EmployeeID WHERE T2.FirstName = 'Michel' AND T2.MiddleInitial = 'e' AND T2.LastName = 'DeFrance'
5,399