1sf/bird-sql-train-with-schema huggingface dataset:
Database: beer_factory
Tables: customers, geolocation, location, rootbeerbrand, rootbeer, rootbeerreview, transaction
Columns (table index, column name): -1, *, 0, CustomerID, 0, First, 0, Last, 0, StreetAddress, 0, City, 0, State, 0, ZipCode, 0, Email, 0, PhoneNumber, 0, FirstPurchaseDate, 0, SubscribedToEmailList, 0, Gender, 1, LocationID, 1, Latitude, 1, Longitude, 2, LocationID, 2, LocationName, 2, StreetAddress, 2, City, 2, State, 2, ZipCode, 3, BrandID, 3, BrandName, 3, FirstBrewedYear, 3, BreweryName, 3, City, 3, State, 3, Country, 3, Description, 3, CaneSugar, 3, CornSyrup, 3, Honey, 3, ArtificialSweetener, 3, Caffeinated, 3, Alcoholic, 3, AvailableInCans, 3, AvailableInBottles, 3, AvailableInKegs, 3, Website, 3, FacebookPage, 3, Twitter, 3, WholesaleCost, 3, CurrentRetailPrice, 4, RootBeerID, 4, BrandID, 4, ContainerType, 4, LocationID, 4, PurchaseDate, 5, CustomerID, 5, BrandID, 5, StarRating, 5, ReviewDate, 5, Review, 6, TransactionID, 6, CreditCardNumber, 6, CustomerID, 6, TransactionDate, 6, CreditCardType, 6, LocationID, 6, RootBeerID, 6, PurchasePrice
Question: Which brewery does the most purchased root beer in 2016 belong to?
Evidence: most purchased root beer refers to MAX(COUNT(BrandID)); in 2016 refers to PurchaseDate > = '2016-01-01' AND PurchaseDate < = '2016-12-31';
SQL: 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
Database: beer_factory
Tables: customers, geolocation, location, rootbeerbrand, rootbeer, rootbeerreview, transaction
Columns (table index, column name): -1, *, 0, CustomerID, 0, First, 0, Last, 0, StreetAddress, 0, City, 0, State, 0, ZipCode, 0, Email, 0, PhoneNumber, 0, FirstPurchaseDate, 0, SubscribedToEmailList, 0, Gender, 1, LocationID, 1, Latitude, 1, Longitude, 2, LocationID, 2, LocationName, 2, StreetAddress, 2, City, 2, State, 2, ZipCode, 3, BrandID, 3, BrandName, 3, FirstBrewedYear, 3, BreweryName, 3, City, 3, State, 3, Country, 3, Description, 3, CaneSugar, 3, CornSyrup, 3, Honey, 3, ArtificialSweetener, 3, Caffeinated, 3, Alcoholic, 3, AvailableInCans, 3, AvailableInBottles, 3, AvailableInKegs, 3, Website, 3, FacebookPage, 3, Twitter, 3, WholesaleCost, 3, CurrentRetailPrice, 4, RootBeerID, 4, BrandID, 4, ContainerType, 4, LocationID, 4, PurchaseDate, 5, CustomerID, 5, BrandID, 5, StarRating, 5, ReviewDate, 5, Review, 6, TransactionID, 6, CreditCardNumber, 6, CustomerID, 6, TransactionDate, 6, CreditCardType, 6, LocationID, 6, RootBeerID, 6, PurchasePrice
Question: What are the full names of the customer who gave River City a 5-star?
Evidence: full name = First, Last; River City refers to BrandName = 'River City'; 5-star refers to StarRating = 5;
SQL: 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
Database: beer_factory
Tables: customers, geolocation, location, rootbeerbrand, rootbeer, rootbeerreview, transaction
Columns (table index, column name): -1, *, 0, CustomerID, 0, First, 0, Last, 0, StreetAddress, 0, City, 0, State, 0, ZipCode, 0, Email, 0, PhoneNumber, 0, FirstPurchaseDate, 0, SubscribedToEmailList, 0, Gender, 1, LocationID, 1, Latitude, 1, Longitude, 2, LocationID, 2, LocationName, 2, StreetAddress, 2, City, 2, State, 2, ZipCode, 3, BrandID, 3, BrandName, 3, FirstBrewedYear, 3, BreweryName, 3, City, 3, State, 3, Country, 3, Description, 3, CaneSugar, 3, CornSyrup, 3, Honey, 3, ArtificialSweetener, 3, Caffeinated, 3, Alcoholic, 3, AvailableInCans, 3, AvailableInBottles, 3, AvailableInKegs, 3, Website, 3, FacebookPage, 3, Twitter, 3, WholesaleCost, 3, CurrentRetailPrice, 4, RootBeerID, 4, BrandID, 4, ContainerType, 4, LocationID, 4, PurchaseDate, 5, CustomerID, 5, BrandID, 5, StarRating, 5, ReviewDate, 5, Review, 6, TransactionID, 6, CreditCardNumber, 6, CustomerID, 6, TransactionDate, 6, CreditCardType, 6, LocationID, 6, RootBeerID, 6, PurchasePrice
Question: How many root beers did Tom Hanks purchase between 2015 to 2016?
Evidence: between 2015 to 2016 refers to TransactionDate > = '2015-01-01' AND TransactionDate < '2016-12-31';
SQL: 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'
Database: beer_factory
Tables: customers, geolocation, location, rootbeerbrand, rootbeer, rootbeerreview, transaction
Columns (table index, column name): -1, *, 0, CustomerID, 0, First, 0, Last, 0, StreetAddress, 0, City, 0, State, 0, ZipCode, 0, Email, 0, PhoneNumber, 0, FirstPurchaseDate, 0, SubscribedToEmailList, 0, Gender, 1, LocationID, 1, Latitude, 1, Longitude, 2, LocationID, 2, LocationName, 2, StreetAddress, 2, City, 2, State, 2, ZipCode, 3, BrandID, 3, BrandName, 3, FirstBrewedYear, 3, BreweryName, 3, City, 3, State, 3, Country, 3, Description, 3, CaneSugar, 3, CornSyrup, 3, Honey, 3, ArtificialSweetener, 3, Caffeinated, 3, Alcoholic, 3, AvailableInCans, 3, AvailableInBottles, 3, AvailableInKegs, 3, Website, 3, FacebookPage, 3, Twitter, 3, WholesaleCost, 3, CurrentRetailPrice, 4, RootBeerID, 4, BrandID, 4, ContainerType, 4, LocationID, 4, PurchaseDate, 5, CustomerID, 5, BrandID, 5, StarRating, 5, ReviewDate, 5, Review, 6, TransactionID, 6, CreditCardNumber, 6, CustomerID, 6, TransactionDate, 6, CreditCardType, 6, LocationID, 6, RootBeerID, 6, PurchasePrice
Question: Which brand of root beer was highly rated by customers?
Evidence: brand of root beer refers to BrandName; highly rated refers to MAX(COUNT(StarRating = 5));
SQL: SELECT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.StarRating = 5
Database: beer_factory
Tables: customers, geolocation, location, rootbeerbrand, rootbeer, rootbeerreview, transaction
Columns (table index, column name): -1, *, 0, CustomerID, 0, First, 0, Last, 0, StreetAddress, 0, City, 0, State, 0, ZipCode, 0, Email, 0, PhoneNumber, 0, FirstPurchaseDate, 0, SubscribedToEmailList, 0, Gender, 1, LocationID, 1, Latitude, 1, Longitude, 2, LocationID, 2, LocationName, 2, StreetAddress, 2, City, 2, State, 2, ZipCode, 3, BrandID, 3, BrandName, 3, FirstBrewedYear, 3, BreweryName, 3, City, 3, State, 3, Country, 3, Description, 3, CaneSugar, 3, CornSyrup, 3, Honey, 3, ArtificialSweetener, 3, Caffeinated, 3, Alcoholic, 3, AvailableInCans, 3, AvailableInBottles, 3, AvailableInKegs, 3, Website, 3, FacebookPage, 3, Twitter, 3, WholesaleCost, 3, CurrentRetailPrice, 4, RootBeerID, 4, BrandID, 4, ContainerType, 4, LocationID, 4, PurchaseDate, 5, CustomerID, 5, BrandID, 5, StarRating, 5, ReviewDate, 5, Review, 6, TransactionID, 6, CreditCardNumber, 6, CustomerID, 6, TransactionDate, 6, CreditCardType, 6, LocationID, 6, RootBeerID, 6, PurchasePrice
Question: How many Henry Weinhard's were bought by Nicholas Sparks?
Evidence: Henry Weinhard's refers to BrandName = 'Henry Weinhard''s';
SQL: 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'
Database: beer_factory
Tables: customers, geolocation, location, rootbeerbrand, rootbeer, rootbeerreview, transaction
Columns (table index, column name): -1, *, 0, CustomerID, 0, First, 0, Last, 0, StreetAddress, 0, City, 0, State, 0, ZipCode, 0, Email, 0, PhoneNumber, 0, FirstPurchaseDate, 0, SubscribedToEmailList, 0, Gender, 1, LocationID, 1, Latitude, 1, Longitude, 2, LocationID, 2, LocationName, 2, StreetAddress, 2, City, 2, State, 2, ZipCode, 3, BrandID, 3, BrandName, 3, FirstBrewedYear, 3, BreweryName, 3, City, 3, State, 3, Country, 3, Description, 3, CaneSugar, 3, CornSyrup, 3, Honey, 3, ArtificialSweetener, 3, Caffeinated, 3, Alcoholic, 3, AvailableInCans, 3, AvailableInBottles, 3, AvailableInKegs, 3, Website, 3, FacebookPage, 3, Twitter, 3, WholesaleCost, 3, CurrentRetailPrice, 4, RootBeerID, 4, BrandID, 4, ContainerType, 4, LocationID, 4, PurchaseDate, 5, CustomerID, 5, BrandID, 5, StarRating, 5, ReviewDate, 5, Review, 6, TransactionID, 6, CreditCardNumber, 6, CustomerID, 6, TransactionDate, 6, CreditCardType, 6, LocationID, 6, RootBeerID, 6, PurchasePrice
Question: Among the root beer brands that do not advertise on Facebook and Twitter, which brand has the highest number of purchases?
Evidence: 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));
SQL: 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
Database: beer_factory
Tables: customers, geolocation, location, rootbeerbrand, rootbeer, rootbeerreview, transaction
Columns (table index, column name): -1, *, 0, CustomerID, 0, First, 0, Last, 0, StreetAddress, 0, City, 0, State, 0, ZipCode, 0, Email, 0, PhoneNumber, 0, FirstPurchaseDate, 0, SubscribedToEmailList, 0, Gender, 1, LocationID, 1, Latitude, 1, Longitude, 2, LocationID, 2, LocationName, 2, StreetAddress, 2, City, 2, State, 2, ZipCode, 3, BrandID, 3, BrandName, 3, FirstBrewedYear, 3, BreweryName, 3, City, 3, State, 3, Country, 3, Description, 3, CaneSugar, 3, CornSyrup, 3, Honey, 3, ArtificialSweetener, 3, Caffeinated, 3, Alcoholic, 3, AvailableInCans, 3, AvailableInBottles, 3, AvailableInKegs, 3, Website, 3, FacebookPage, 3, Twitter, 3, WholesaleCost, 3, CurrentRetailPrice, 4, RootBeerID, 4, BrandID, 4, ContainerType, 4, LocationID, 4, PurchaseDate, 5, CustomerID, 5, BrandID, 5, StarRating, 5, ReviewDate, 5, Review, 6, TransactionID, 6, CreditCardNumber, 6, CustomerID, 6, TransactionDate, 6, CreditCardType, 6, LocationID, 6, RootBeerID, 6, PurchasePrice
Question: Between Sac State Union and Sac State American River Courtyard, which location sold the most Dog n Suds root beer?
Evidence: Between Sac State Union and Sac State American River Courtyard refers to LocationName IN('Sac State American River Courtyard', 'Sac State Union'); Dog n Suds refers to BrandName = 'Dog n Suds'; sold the most root beer refers to MAX(COUNT(BrandID));
SQL: 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
Database: beer_factory
Tables: customers, geolocation, location, rootbeerbrand, rootbeer, rootbeerreview, transaction
Columns (table index, column name): -1, *, 0, CustomerID, 0, First, 0, Last, 0, StreetAddress, 0, City, 0, State, 0, ZipCode, 0, Email, 0, PhoneNumber, 0, FirstPurchaseDate, 0, SubscribedToEmailList, 0, Gender, 1, LocationID, 1, Latitude, 1, Longitude, 2, LocationID, 2, LocationName, 2, StreetAddress, 2, City, 2, State, 2, ZipCode, 3, BrandID, 3, BrandName, 3, FirstBrewedYear, 3, BreweryName, 3, City, 3, State, 3, Country, 3, Description, 3, CaneSugar, 3, CornSyrup, 3, Honey, 3, ArtificialSweetener, 3, Caffeinated, 3, Alcoholic, 3, AvailableInCans, 3, AvailableInBottles, 3, AvailableInKegs, 3, Website, 3, FacebookPage, 3, Twitter, 3, WholesaleCost, 3, CurrentRetailPrice, 4, RootBeerID, 4, BrandID, 4, ContainerType, 4, LocationID, 4, PurchaseDate, 5, CustomerID, 5, BrandID, 5, StarRating, 5, ReviewDate, 5, Review, 6, TransactionID, 6, CreditCardNumber, 6, CustomerID, 6, TransactionDate, 6, CreditCardType, 6, LocationID, 6, RootBeerID, 6, PurchasePrice
Question: How many canned A&W were purchased in 2016?
Evidence: canned refers to ContainerType = 'Can'; A&W refers to BrandName = 'A&W'; in 2016 refers to PurchaseDate > = '2016-01-01' AND PurchaseDate < = '2016-12-31';
SQL: 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%'
Database: beer_factory
Tables: customers, geolocation, location, rootbeerbrand, rootbeer, rootbeerreview, transaction
Columns (table index, column name): -1, *, 0, CustomerID, 0, First, 0, Last, 0, StreetAddress, 0, City, 0, State, 0, ZipCode, 0, Email, 0, PhoneNumber, 0, FirstPurchaseDate, 0, SubscribedToEmailList, 0, Gender, 1, LocationID, 1, Latitude, 1, Longitude, 2, LocationID, 2, LocationName, 2, StreetAddress, 2, City, 2, State, 2, ZipCode, 3, BrandID, 3, BrandName, 3, FirstBrewedYear, 3, BreweryName, 3, City, 3, State, 3, Country, 3, Description, 3, CaneSugar, 3, CornSyrup, 3, Honey, 3, ArtificialSweetener, 3, Caffeinated, 3, Alcoholic, 3, AvailableInCans, 3, AvailableInBottles, 3, AvailableInKegs, 3, Website, 3, FacebookPage, 3, Twitter, 3, WholesaleCost, 3, CurrentRetailPrice, 4, RootBeerID, 4, BrandID, 4, ContainerType, 4, LocationID, 4, PurchaseDate, 5, CustomerID, 5, BrandID, 5, StarRating, 5, ReviewDate, 5, Review, 6, TransactionID, 6, CreditCardNumber, 6, CustomerID, 6, TransactionDate, 6, CreditCardType, 6, LocationID, 6, RootBeerID, 6, PurchasePrice
Question: What is the precise location of Sac State Union?
Evidence: precise location = Latitude, Longitude; Sac State Union refers to LocationName = 'Sac State Union';
SQL: 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'
Database: beer_factory
Tables: customers, geolocation, location, rootbeerbrand, rootbeer, rootbeerreview, transaction
Columns (table index, column name): -1, *, 0, CustomerID, 0, First, 0, Last, 0, StreetAddress, 0, City, 0, State, 0, ZipCode, 0, Email, 0, PhoneNumber, 0, FirstPurchaseDate, 0, SubscribedToEmailList, 0, Gender, 1, LocationID, 1, Latitude, 1, Longitude, 2, LocationID, 2, LocationName, 2, StreetAddress, 2, City, 2, State, 2, ZipCode, 3, BrandID, 3, BrandName, 3, FirstBrewedYear, 3, BreweryName, 3, City, 3, State, 3, Country, 3, Description, 3, CaneSugar, 3, CornSyrup, 3, Honey, 3, ArtificialSweetener, 3, Caffeinated, 3, Alcoholic, 3, AvailableInCans, 3, AvailableInBottles, 3, AvailableInKegs, 3, Website, 3, FacebookPage, 3, Twitter, 3, WholesaleCost, 3, CurrentRetailPrice, 4, RootBeerID, 4, BrandID, 4, ContainerType, 4, LocationID, 4, PurchaseDate, 5, CustomerID, 5, BrandID, 5, StarRating, 5, ReviewDate, 5, Review, 6, TransactionID, 6, CreditCardNumber, 6, CustomerID, 6, TransactionDate, 6, CreditCardType, 6, LocationID, 6, RootBeerID, 6, PurchasePrice
Question: What are the brands of the root beers that received 5-star ratings from no less than 5 customers?
Evidence: brand of the root beer refers to BrandName; 5-star ratings refers to StarRating = 5; no less than 5 customers refers to COUNT(CustomerID) > = 5;
SQL: 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
Database: beer_factory
Tables: customers, geolocation, location, rootbeerbrand, rootbeer, rootbeerreview, transaction
Columns (table index, column name): -1, *, 0, CustomerID, 0, First, 0, Last, 0, StreetAddress, 0, City, 0, State, 0, ZipCode, 0, Email, 0, PhoneNumber, 0, FirstPurchaseDate, 0, SubscribedToEmailList, 0, Gender, 1, LocationID, 1, Latitude, 1, Longitude, 2, LocationID, 2, LocationName, 2, StreetAddress, 2, City, 2, State, 2, ZipCode, 3, BrandID, 3, BrandName, 3, FirstBrewedYear, 3, BreweryName, 3, City, 3, State, 3, Country, 3, Description, 3, CaneSugar, 3, CornSyrup, 3, Honey, 3, ArtificialSweetener, 3, Caffeinated, 3, Alcoholic, 3, AvailableInCans, 3, AvailableInBottles, 3, AvailableInKegs, 3, Website, 3, FacebookPage, 3, Twitter, 3, WholesaleCost, 3, CurrentRetailPrice, 4, RootBeerID, 4, BrandID, 4, ContainerType, 4, LocationID, 4, PurchaseDate, 5, CustomerID, 5, BrandID, 5, StarRating, 5, ReviewDate, 5, Review, 6, TransactionID, 6, CreditCardNumber, 6, CustomerID, 6, TransactionDate, 6, CreditCardType, 6, LocationID, 6, RootBeerID, 6, PurchasePrice
Question: List the brands of root beer produced by Dr Pepper Snapple Group and calculate their percentage of purchases between 2014 to 2016.
Evidence: brand of root beer refers to BrandName; produced by Dr Pepper Snapple Group refers to BreweryName = 'Dr Pepper Snapple Group'; percentage of purchases = MULTIPLY(DIVIDE(SUM(BrandID WHERE PurchaseDate > = '2014-01-01' AND PurchaseDate < = '2016-12-31'), COUNT(BrandID) WHERE BreweryName = 'Dr Pepper Snapple Group'), 1.0); between 2014 to 2016 refers to PurchaseDate > = '2014-01-01' AND PurchaseDate < = '2016-12-31;
SQL: 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
Database: beer_factory
Tables: customers, geolocation, location, rootbeerbrand, rootbeer, rootbeerreview, transaction
Columns (table index, column name): -1, *, 0, CustomerID, 0, First, 0, Last, 0, StreetAddress, 0, City, 0, State, 0, ZipCode, 0, Email, 0, PhoneNumber, 0, FirstPurchaseDate, 0, SubscribedToEmailList, 0, Gender, 1, LocationID, 1, Latitude, 1, Longitude, 2, LocationID, 2, LocationName, 2, StreetAddress, 2, City, 2, State, 2, ZipCode, 3, BrandID, 3, BrandName, 3, FirstBrewedYear, 3, BreweryName, 3, City, 3, State, 3, Country, 3, Description, 3, CaneSugar, 3, CornSyrup, 3, Honey, 3, ArtificialSweetener, 3, Caffeinated, 3, Alcoholic, 3, AvailableInCans, 3, AvailableInBottles, 3, AvailableInKegs, 3, Website, 3, FacebookPage, 3, Twitter, 3, WholesaleCost, 3, CurrentRetailPrice, 4, RootBeerID, 4, BrandID, 4, ContainerType, 4, LocationID, 4, PurchaseDate, 5, CustomerID, 5, BrandID, 5, StarRating, 5, ReviewDate, 5, Review, 6, TransactionID, 6, CreditCardNumber, 6, CustomerID, 6, TransactionDate, 6, CreditCardType, 6, LocationID, 6, RootBeerID, 6, PurchasePrice
Question: 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.
Evidence: brand of root beer refers to BrandName; lowest unit profit available to wholesalers refers to MIN(SUBTRACT(CurrentRetailPrice, WholesaleCost)); ID of the customer refers to CustomerID; highest number of purchases refers to MAX(COUNT(CustomerID));
SQL: 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
Database: beer_factory
Tables: customers, geolocation, location, rootbeerbrand, rootbeer, rootbeerreview, transaction
Columns (table index, column name): -1, *, 0, CustomerID, 0, First, 0, Last, 0, StreetAddress, 0, City, 0, State, 0, ZipCode, 0, Email, 0, PhoneNumber, 0, FirstPurchaseDate, 0, SubscribedToEmailList, 0, Gender, 1, LocationID, 1, Latitude, 1, Longitude, 2, LocationID, 2, LocationName, 2, StreetAddress, 2, City, 2, State, 2, ZipCode, 3, BrandID, 3, BrandName, 3, FirstBrewedYear, 3, BreweryName, 3, City, 3, State, 3, Country, 3, Description, 3, CaneSugar, 3, CornSyrup, 3, Honey, 3, ArtificialSweetener, 3, Caffeinated, 3, Alcoholic, 3, AvailableInCans, 3, AvailableInBottles, 3, AvailableInKegs, 3, Website, 3, FacebookPage, 3, Twitter, 3, WholesaleCost, 3, CurrentRetailPrice, 4, RootBeerID, 4, BrandID, 4, ContainerType, 4, LocationID, 4, PurchaseDate, 5, CustomerID, 5, BrandID, 5, StarRating, 5, ReviewDate, 5, Review, 6, TransactionID, 6, CreditCardNumber, 6, CustomerID, 6, TransactionDate, 6, CreditCardType, 6, LocationID, 6, RootBeerID, 6, PurchasePrice
Question: List the full name and phone number of male customers from Fair Oaks who are subscribed to the email list.
Evidence: 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';
SQL: SELECT First, Last, PhoneNumber FROM customers WHERE Gender = 'M' AND City = 'Fair Oaks' AND SubscribedToEmailList = 'TRUE'
Database: beer_factory
Tables: customers, geolocation, location, rootbeerbrand, rootbeer, rootbeerreview, transaction
Columns (table index, column name): -1, *, 0, CustomerID, 0, First, 0, Last, 0, StreetAddress, 0, City, 0, State, 0, ZipCode, 0, Email, 0, PhoneNumber, 0, FirstPurchaseDate, 0, SubscribedToEmailList, 0, Gender, 1, LocationID, 1, Latitude, 1, Longitude, 2, LocationID, 2, LocationName, 2, StreetAddress, 2, City, 2, State, 2, ZipCode, 3, BrandID, 3, BrandName, 3, FirstBrewedYear, 3, BreweryName, 3, City, 3, State, 3, Country, 3, Description, 3, CaneSugar, 3, CornSyrup, 3, Honey, 3, ArtificialSweetener, 3, Caffeinated, 3, Alcoholic, 3, AvailableInCans, 3, AvailableInBottles, 3, AvailableInKegs, 3, Website, 3, FacebookPage, 3, Twitter, 3, WholesaleCost, 3, CurrentRetailPrice, 4, RootBeerID, 4, BrandID, 4, ContainerType, 4, LocationID, 4, PurchaseDate, 5, CustomerID, 5, BrandID, 5, StarRating, 5, ReviewDate, 5, Review, 6, TransactionID, 6, CreditCardNumber, 6, CustomerID, 6, TransactionDate, 6, CreditCardType, 6, LocationID, 6, RootBeerID, 6, PurchasePrice
Question: Among the root beer purchased in 2014, what percentage were sold in cans?
Evidence: in 2014 refers to PurchaseDate > = '2014-01-01' AND PurchaseDate < = '2014-12-31'; percentage = MULTIPLY(DIVIDE(SUM(ContainerType = 'Can'), COUNT(RootBeerID) WHERE PurchaseDate > = '2014-01-01' AND PurchaseDate < = '2014-12-31'), 1.0); in cans refers to ContainerType = 'Can';
SQL: SELECT CAST(COUNT(CASE WHEN ContainerType = 'Can' THEN RootBeerID ELSE NULL END) AS REAL) * 100 / COUNT(RootBeerID) FROM rootbeer WHERE PurchaseDate LIKE '2014%'
Database: beer_factory
Tables: customers, geolocation, location, rootbeerbrand, rootbeer, rootbeerreview, transaction
Columns (table index, column name): -1, *, 0, CustomerID, 0, First, 0, Last, 0, StreetAddress, 0, City, 0, State, 0, ZipCode, 0, Email, 0, PhoneNumber, 0, FirstPurchaseDate, 0, SubscribedToEmailList, 0, Gender, 1, LocationID, 1, Latitude, 1, Longitude, 2, LocationID, 2, LocationName, 2, StreetAddress, 2, City, 2, State, 2, ZipCode, 3, BrandID, 3, BrandName, 3, FirstBrewedYear, 3, BreweryName, 3, City, 3, State, 3, Country, 3, Description, 3, CaneSugar, 3, CornSyrup, 3, Honey, 3, ArtificialSweetener, 3, Caffeinated, 3, Alcoholic, 3, AvailableInCans, 3, AvailableInBottles, 3, AvailableInKegs, 3, Website, 3, FacebookPage, 3, Twitter, 3, WholesaleCost, 3, CurrentRetailPrice, 4, RootBeerID, 4, BrandID, 4, ContainerType, 4, LocationID, 4, PurchaseDate, 5, CustomerID, 5, BrandID, 5, StarRating, 5, ReviewDate, 5, Review, 6, TransactionID, 6, CreditCardNumber, 6, CustomerID, 6, TransactionDate, 6, CreditCardType, 6, LocationID, 6, RootBeerID, 6, PurchasePrice
Question: Give the name of the brands that brewed their first drink between 1996 and 2000 in the descending order of the date brewed.
Evidence: name of the brands refers to BrandName; between 1996 and 2000 refers to FirstBrewedYear > = 1996 AND FirstBrewedYear < = 2000;
SQL: SELECT BrandName FROM rootbeerbrand WHERE FirstBrewedYear BETWEEN '1996' AND '2000' ORDER BY FirstBrewedYear DESC