db_id
stringclasses 68
values | question
stringlengths 33
321
| evidence
stringlengths 0
673
| SQL
stringlengths 116
743
| question_id
int64 3
6.6k
| difficulty
stringclasses 2
values |
---|---|---|---|---|---|
beer_factory | Of the 4 root beers that Frank-Paul Santangelo purchased on 2014/7/7, how many of them were in cans? | on 2014/7/7 refers to transactiondate = '2014-07-07'; in cans refers to containertype = 'Can'; | 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' | 303 | moderate |
beer_factory | What is the average number of root beers of the brand A&W sold in a day in August, 2014? | average = DIVIDE(SUM(COUNT(RootBeerID WHERE BrandName = 'A&W' AND SUBSTR(TransactionDate, 1, 4) = '2014' AND SUBSTR(TransactionDate, 6, 2) = '08')), 31); A&W refers to BrandName = 'A&W'; in August, 2014 refers to SUBSTR(TransactionDate, 1, 4) = '2014' AND SUBSTR(TransactionDate, 6, 2) = '08'; | 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' | 5,351 | moderate |
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%' | 6,088 | moderate |
beer_factory | What is the number of the credit card that Frank-Paul Santangelo used to purchase root beers on 2014/7/7? | number of the credit card refers to CreditCardNumber; on 2014/7/7 refers to TransactionDate = '2014-07-07'; | 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' | 960 | moderate |
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 | 6,360 | challenging |
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' | 3 | challenging |
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') | 2,334 | moderate |
beer_factory | Which brewery does the most purchased root beer in 2016 belong to? | most purchased root beer refers to MAX(COUNT(BrandID)); in 2016 refers to PurchaseDate > = '2016-01-01' AND PurchaseDate < = '2016-12-31'; | SELECT T2.BreweryName FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID WHERE T1.PurchaseDate BETWEEN '2016-01-01' AND '2016-12-31' GROUP BY T2.BrandID ORDER BY COUNT(T1.BrandID) DESC LIMIT 1 | 2,907 | moderate |
beer_factory | Among the transactions made in July, 2014, how many of them were made by a male customer? | in July, 2014 refers to SUBSTR(TransactionDate, 1, 4) = '2014' AND SUBSTR(TransactionDate, 6, 2) = '07'; male customer refers to Gender = 'M'; | 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' | 6,452 | moderate |
beer_factory | For the root beer brand which got the review with the content of "The quintessential dessert root beer. No ice cream required.", what is the current retail price of the root beer? | review with the content of "The quintessential dessert root beer. No ice cream required." refers to Review = 'The quintessential dessert root beer. No ice cream required.'; | SELECT T1.CurrentRetailPrice - T1.WholesaleCost AS price FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.Review = 'The quintessential dessert root beer. No ice cream required.' | 1,856 | moderate |
beer_factory | What are the brands of the root beers that received 5-star ratings from no less than 5 customers? | 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; | 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 | 4,267 | moderate |
beer_factory | Among the root beer purchased in 2014, what percentage were sold in cans? | 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'; | SELECT CAST(COUNT(CASE WHEN ContainerType = 'Can' THEN RootBeerID ELSE NULL END) AS REAL) * 100 / COUNT(RootBeerID) FROM rootbeer WHERE PurchaseDate LIKE '2014%' | 4,105 | moderate |
beer_factory | 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? | users permit the company to send regular emails to them refers to subscribedtoemaillist = 'TRUE'; Visa card refers to creditcardtype = 'Visa'; in July, 2014 refers to SUBSTR(TransactionDate, 1, 4) = '2014' AND SUBSTR(TransactionDate, 6, 2) = '07'; | 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' | 1,798 | moderate |
beer_factory | What is the average cost of root beers purchased for more than 2 dollars and sold in bottles? | average cost = DIVIDE(SUM(PurchasePrice > 2), COUNT(RootBeerID) WHERE PurchasePrice > 2); more than 2 dollars refers to PurchasePrice > 2; in bottles refers to ContainerType = 'Bottle'; | SELECT AVG(T2.PurchasePrice) FROM rootbeer AS T1 INNER JOIN `transaction` AS T2 ON T1.RootBeerID = T2.RootBeerID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID WHERE T1.ContainerType = 'Bottle' AND T2.PurchasePrice > 2 | 3,803 | moderate |
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 | 2,878 | challenging |
beer_factory | 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. | 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)); | 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 | 5,753 | moderate |
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 | 4,675 | moderate |
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,291 | challenging |
beer_factory | What is the average number of reviews of all the root beer brands from "CA" State? | average = DIVIDE(COUNT(CustomerID), COUNT(BrandID) WHERE state = CA);
| SELECT CAST(COUNT(*) AS REAL) / COUNT(DISTINCT T1.BrandID) AS avgreview FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T1.State = 'CA' | 1,595 | moderate |
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' | 2,683 | moderate |
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' | 3,571 | moderate |
beer_factory | Calculate the percentage of sales done at Sac State American River Courtyard. | percentage = MULTIPLY(DIVIDE(SUM(LocationName = 'Sac State American River Courtyard'), COUNT(LocationID)), 1.0); Sac State American River Courtyard refers to LocationName = 'Sac State American River Courtyard'; | SELECT CAST(COUNT(CASE WHEN T2.LocationName = 'Sac State American River Courtyard' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.TransactionID) FROM `transaction` AS T1 INNER JOIN location AS T2 ON T1.LocationID = T2.LocationID | 821 | moderate |
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 | 1,703 | moderate |
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 | 831 | moderate |
beer_factory | Among all the root beers purchased by Frank-Paul Santangelo, how many of them were non-sweetened? | non-sweetened refers to honey = 'FALSE' AND artificialsweetener = 'FALSE'; | 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' | 532 | moderate |
beer_factory | Among the root beer brands that do not advertise on Twitter, how many of them have root beers sold in August, 2014? | do not advertise on Twitter refers to twitter IS NULL; in August, 2014 refers to SUBSTR(TransactionDate, 1, 4) = '2014' AND SUBSTR(TransactionDate, 6, 2) = '08'; | 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 | 5,758 | moderate |
beer_factory | For the root beer brand with the most 5 star ratings, what is the name of the brewery? | most 5 star ratings refers to MAX(COUNT(StarRating = 5)); name of the brewery refers to BreweryName; | SELECT T1.BreweryName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.StarRating = 5 GROUP BY T1.BrandID ORDER BY COUNT(T2.StarRating) DESC LIMIT 1 | 349 | moderate |
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%' | 3,824 | moderate |
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 | 4,882 | challenging |
beer_factory | List the brands of root beer produced by Dr Pepper Snapple Group and calculate their percentage of purchases between 2014 to 2016. | 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; | 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 | 4,043 | challenging |
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 | 2,578 | moderate |
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.' | 2,425 | moderate |
bike_share_1 | What is the location coordinates of the bike station from which the bike for the trip that last the longest was borrowed? | location coordinates refers to (lat, long); bike that was borrowed the longest refers to MAX(duration); | SELECT T2.lat, T2.long FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.duration = ( SELECT MAX(T1.duration) FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name ) | 432 | moderate |
bike_share_1 | How many bike stations are installed after August, 2013 in San Jose? | installed after August, 2013 refers to year(installation_date)>2013; in San Jose refers to city = 'San Jose'; | SELECT COUNT(installation_date) FROM station WHERE city = 'San Jose' AND (SUBSTR(CAST(installation_date AS TEXT), 1, INSTR(installation_date, '/') - 1) IN ('8', '9', '10', '11', '12') AND SUBSTR(CAST(installation_date AS TEXT), -4) = '2013') OR SUBSTR(CAST(installation_date AS TEXT), -4) > '2013' | 5,268 | challenging |
bike_share_1 | List the name of stations that were installed from 8/5/2013 to 12/31/2013. Indicate their installation date and city name. | from 8/5/2013 to 12/31/2013 refers to installation_date between '8/5/2013' and '12/31/2013'; | SELECT name, installation_date, city FROM station WHERE (SUBSTR(CAST(installation_date AS TEXT), 1, INSTR(installation_date, '/') - 1) = '5' AND SUBSTR(CAST(installation_date AS TEXT), INSTR(installation_date, '/') + 1, -6) >= '8' AND SUBSTR(CAST(installation_date AS TEXT), -4) = '2013') OR (SUBSTR(CAST(installation_date AS TEXT), 1, INSTR(installation_date, '/') - 1) IN ( '6', '7', '8', '9', '10', '11', '12' ) AND SUBSTR(CAST(installation_date AS TEXT), -4) = '2013') | 5,678 | challenging |
bike_share_1 | Which trip id had the longest duration and the start station is in Redwood City? | longest duration refers to MAX(duration); start station refers to start_station_name; | SELECT T1.id FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.city = 'Redwood City' AND T1.duration = ( SELECT MAX(T1.duration) FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.city = 'Redwood City' ) | 1,479 | moderate |
bike_share_1 | On 8/29/2013, who took the longest to arrive in California Ave Caltrain Station from University and Emerson? Indicate the bike id. | start_date = '8/29/2013'; end_date = '8/29/2013'; end_station_name = 'California Ave Caltrain Station'; start_station_name = 'University and Emerson'; who took the longest to arrive refers to MAX(duration); | SELECT bike_id FROM trip WHERE start_date LIKE '8/29/2013%' AND end_date LIKE '8/29/2013%' AND end_station_name = 'California Ave Caltrain Station' AND start_station_name = 'University and Emerson' AND duration = ( SELECT MAX(duration) FROM trip WHERE start_date LIKE '8/29/2013%' AND end_date LIKE '8/29/2013%' AND end_station_name = 'California Ave Caltrain Station' AND start_station_name = 'University and Emerson' ) | 126 | challenging |
bike_share_1 | Which day in the month of November, 2014 have a foggy weather in the zip code 94301 and in total, how many bikes were borrowed by subscribers from all of the stations in the said day? | day in the month of November, 2014 refers to start_date between '11/1/2014' and '11/30/2014'; foggy weather refers to events = 'Fog'; subscriber refers to subscription_type; all of the stations bikes were borrowed from refer to start_station_name; | SELECT T2.date, COUNT(T1.start_station_name) FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code WHERE T2.date LIKE '11/%/2014%' AND T2.zip_code = 94301 AND T2.events = 'Fog' AND T1.subscription_type = 'Subscriber' | 6,213 | moderate |
bike_share_1 | What is the average duration of a bike trip made on the day with the hottest temperature ever in 2014? | average duration = DIVIDE(SUM(duration), COUNT(id)); hottest temperature refers to max_temperature_f; in 2014 refers to date LIKE '%2014'; | SELECT AVG(T1.duration) FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code WHERE T2.date LIKE '%2014%' AND T1.start_station_name = '2nd at Folsom' AND T2.max_temperature_f = ( SELECT max_temperature_f FROM weather ORDER BY max_temperature_f DESC LIMIT 1 ) | 32 | moderate |
bike_share_1 | Which year had the most number of trips that started at stations in San Francisco? | started at station refers to start_station_name; San Francisco refers to city = 'San Francisco'; year that had the most number of trips refers to MAX(year(start_date)); | SELECT SUBSTR(CAST(T1.start_date AS TEXT), INSTR(T1.start_date, ' '), -4) FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.city = 'San Francisco' GROUP BY T1.start_station_name ORDER BY COUNT(T1.id) DESC LIMIT 1 | 3,644 | moderate |
bike_share_1 | For the rides that started at Market at 10th station and ended at South Van Ness at Market station in August of 2013, which day had the coldest temperature? | started at refers to start_station_name; start_station_name = 'Market at 10th'; ended at refers to end_station_name; end_station_name = 'South Van Ness at Market'; in August of 2013 refers to start_date BETWEEN '8/1/2013 0:00' AND '8/31/2013 12:59'; day that had the coldest temperature refers to MIN(min_temperature_f); | SELECT T1.start_date FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code AND T2.date = SUBSTR(CAST(T1.start_date AS TEXT), 1, INSTR(T1.start_date, ' ') - 1) WHERE T2.date LIKE '8/%/2013' AND T1.start_station_name = 'Market at 10th' AND T1.end_station_name = 'South Van Ness at Market' AND T2.min_temperature_f = ( SELECT MIN(T2.min_temperature_f) FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code AND T2.date = SUBSTR(CAST(T1.start_date AS TEXT), 1, INSTR(T1.start_date, ' ') - 1) WHERE T2.date LIKE '8/%/2013' AND T1.start_station_name = 'Market at 10th' AND T1.end_station_name = 'South Van Ness at Market' ) | 10 | challenging |
bike_share_1 | Name all the trip on the days when it rained. State the duration of the trip | events = 'Rain'; | SELECT T1.id, T1.duration FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code AND T2.date = SUBSTR(CAST(T1.start_date AS TEXT), 1, INSTR(T1.start_date, ' ') - 1) WHERE T2.events LIKE '%Rain%' OR T2.events LIKE '%rain%' | 2,168 | challenging |
bike_share_1 | What is the ratio for subscriber to customer given that the starting and the ending stations is 2nd at South Park? | subscriber refers to subscription_type = 'Subscriber'; customer refers to subscription_type = 'customer';starting station refers to start_station_name; ending station refers to end_statio_name; start_station_name = '2nd at South Park' AND end_station_name = '2nd at South Park' | SELECT CAST(SUM(IIF(subscription_type = 'Subscriber', 1, 0)) AS REAL) / SUM(IIF(subscription_type = 'Customer', 1, 0)) FROM trip WHERE start_station_name = '2nd at South Park' AND end_station_name = '2nd at South Park' | 6,215 | moderate |
bike_share_1 | Find the longest ride on foggy day. What were the mean visibility, mean wind speed, and weather event during that ride? Also, list the coordinates and names of the start and end stations. | foggy day refers to events = 'fog'; longest ride on a foggy day refers to MAX(duration) where events = 'fog'; mean visibility refers to mean_visibility_miles; mean wind speed refers to mean_wind_speed_mph; weather event refers to events; coordinates refers to (lat, long); start station refers to start_station_id; end station refers to end_station_id; | SELECT T3.mean_visibility_miles, T3.mean_wind_speed_mph, T3.events, T1.lat, T1.long , T2.start_station_name, T2.end_station_name FROM station AS T1 INNER JOIN trip AS T2 ON T2.start_station_name = T1.name INNER JOIN weather AS T3 ON T3.zip_code = T2.zip_code WHERE T3.events = 'Fog' ORDER BY T2.duration DESC LIMIT 1 | 1,307 | moderate |
bike_share_1 | Which bicycle is the least used bike. Check if the start and end station are from the same city and calculate the total duration travelled by the bicycle in hours for a trip made within the same city. | least used bike refers to bike_id with MIN(COUNT(main_trip.id)); start station refers to start_station_name; end station refers to end_station_name; total duration in hour = DIVIDE(duration, 3600) AS hour; | SELECT T2.bike_id, T2.start_station_name, T2.end_station_name, T1.city , CAST(T2.duration AS REAL) / 3600 FROM station AS T1 INNER JOIN trip AS T2 ON T1.name = T2.start_station_name GROUP BY T2.bike_id ORDER BY COUNT(T2.id) DESC LIMIT 1 | 6,099 | moderate |
bike_share_1 | Calculate the difference between the number of customers and the number of subscribers who did the trip in June 2013. | customer refers to subscription_type = 'Customer'; subscribers refers to subscription_type = 'Subscriber'; difference = SUBTRACT(SUM(subscription_type = 'Subscriber' t), SUM(subscription_type = 'Customer')); trip in June 2013 refers to start_date BETWEEN '6/1/2013 0:00'AND '6/31/2013 12:59'; | SELECT SUM(IIF(subscription_type = 'Subscriber', 1, 0)) - SUM(IIF(subscription_type = 'Customer', 1, 0)) FROM trip WHERE start_date LIKE '6/%/2013%' | 6,280 | moderate |
bike_share_1 | Calculate the average duration travelled by subscribers that both started and ended their trip in Mountain View City Hall and indicate the date when the station was first installed. | average duration = DIVIDE(SUM(duration), COUNT(id)); subscribers refers to subscription_type = 'subscriptions'; started and ended their trip at Mountain View City Hall refers to start_station_name = 'Mountain View City Hall' and end_station_name = 'Mountain View City Hall'; when the station was first installed refers to installation_date; | SELECT AVG(T1.duration), T2.installation_date FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.start_station_name = 'Mountain View City Hall' AND T1.subscription_type = 'Subscriber' AND T1.end_station_name = 'Mountain View City Hall' | 2,825 | moderate |
bike_share_1 | How many bicycle trip were made within San Jose city during August 2013? | during August 2013 refers to start_date like '8/%/2013%'; | SELECT COUNT(T2.id) FROM station AS T1 INNER JOIN trip AS T2 ON T2.start_station_name = T1.name WHERE T1.city = 'San Jose' AND T2.start_date LIKE '8/%/2013%' AND T2.start_station_name LIKE 'San Jose%' AND T2.end_station_name LIKE 'San Jose%' | 5,046 | moderate |
bike_share_1 | How many bike trips started on the days in September, 2013 with the hottest temperature over 70 degrees Fahrenheit in the area where the zip code is 94107? | started on the days in September, 2013 refers to date LIKE'9%'AND date LIKE'%2013' hottest temperature over 70 degrees Fahrenheit refers to max_temperature_f>70; | SELECT COUNT(T1.id) FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code WHERE T2.date LIKE '9/%/2013' AND T2.zip_code = 94107 AND T2.max_temperature_f > 70 | 5,059 | moderate |
bike_share_1 | In 2015, what percentage of trips that had the subscription type was Customer and ended on a rainy day? | in 2015 refers to end_date like '%2015%'; percentage = DIVIDE(COUNT(events = 'Rain'), COUNT(events)); | SELECT CAST(SUM(CASE WHEN T2.events = 'Rain' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.id) FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code WHERE SUBSTR(CAST(T2.date AS TEXT), -4) = '2015' AND T1.subscription_type = 'Customer' | 5,519 | moderate |
bike_share_1 | Among the subscriber, how many of them finished the 2nd at Folsom and Civic Center BART (7th at Market) as their start and end stations respectively for no more than 490 seconds under minimum visibility of 4 miles. | subscription_type = 'Subscriber'; no more than 490 seconds refers to duration<490; start_station_name = '2nd at Folsom'; end_station_name = 'Civic Center BART (7th at Market)'; min_visibility_miles = 4; | SELECT COUNT(T1.id) FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code WHERE T1.subscription_type = 'Subscriber' AND T2.min_visibility_miles = 4 AND T1.duration < 490 AND T1.start_station_name = '2nd at Folsom' AND T1.end_station_name = 'Civic Center BART (7th at Market)' | 5,061 | moderate |
bike_share_1 | What is the ratio of customer to subscriber that making a trip inside Mountain View city? | customer refers to subscription_type = 'customer'; subscriber refers to subscription_type = 'subscriber'; ratio = MULTIPLY(DIVIDE(COUNT(subscription_type = 'Customer'), COUNT(subscription_type = 'Subscriber'). 1.0)) AS ratio; | SELECT CAST(SUM(CASE WHEN T1.subscription_type = 'Customer' THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(CASE WHEN T1.subscription_type = 'Subscriber' THEN 1 ELSE 0 END) FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.city = 'Mountain View' | 4,672 | moderate |
bike_share_1 | List the days in 2013 when rain and fog occurred together and find the id of bikes borrowed on these days. | in 2013 refers to year(date) = 2013; rain and fog ocurred together refers to events = 'Fog-Rain'; id of bikes refers to biked_id; | SELECT T2.date, T1.bike_id FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code WHERE SUBSTR(CAST(T2.date AS TEXT), -4) = '2013' AND T2.events = 'Fog-Rain' | 2,745 | moderate |
bike_share_1 | What is the percentage ration of customers to subscribers that started their trips within the city of San Francisco? | customer refers to subscription_type = 'customer'; subscriber refers to subscription_type = 'subscriber'; started their trips within refers to start_station_id; percentage ratio = DIVIDE(SUM(subscription_type = 'Customer'), SUM(subscription_type = 'Subscriber')) as percentage; | SELECT CAST(SUM(CASE WHEN T1.subscription_type = 'Customer' THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(CASE WHEN T1.subscription_type = 'Subscriber' THEN 1 ELSE 0 END) FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.city = 'San Francisco' | 2,704 | moderate |
bike_share_1 | What is the maximum humidity in Powell Street BART when bike 496 was borrowed from the station on 8/29/2013? | Powell Street refers to start_station_name; bike 496 refers to bike_id = '496'; start_date = '8/29/2013'; | SELECT T2.max_humidity FROM trip AS T1 INNER JOIN weather AS T2 ON T2.zip_code = T1.zip_code WHERE T1.start_date LIKE '8/29/2013%' AND T1.bike_id = 496 AND T1.start_station_name = 'Powell Street BART' | 2,020 | moderate |
bike_share_1 | How many trips made by a subscriber started in August, 2013 from a station that can hold more than 20 bikes? | subscriber refers to subscription_type = 'Subscriber'; in August 2013 refers to start_date LIKE'8%' AND start_date LIKE'%2013%'; station that can hold more than 20 bikes refers to dock_count>20; | SELECT COUNT(T2.id) FROM station AS T1 INNER JOIN trip AS T2 ON T1.id = T2.start_station_id WHERE T2.subscription_type = 'Subscriber' AND T2.start_date LIKE '8/%/2013%' AND T1.dock_count > 20 | 3,233 | moderate |
bike_share_1 | What is the average duration of trips for the starting station of Santa Clara at Almaden and what is the latitude and longitude of this station? | average duration = DIVIDE(SUM(duration), COUNT(id)); starting station refers to start_station_name; start_station_name = 'Santa Clara at Almaden'; latitude refers to lat; longitude refers to long; | SELECT AVG(T1.duration), T2.lat, T2.long FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name LEFT JOIN station AS T3 ON T3.name = T1.end_station_name WHERE T1.start_station_name = 'Santa Clara at Almaden' | 1,352 | moderate |
bike_share_1 | Which year experienced the most rain? | events = 'Rain'; year refers to YEAR(date); | SELECT SUBSTR(CAST(date AS TEXT), -4) FROM weather GROUP BY SUBSTR(CAST(date AS TEXT), -4) ORDER BY SUM(CASE WHEN events LIKE '%Rain%' OR events LIKE '%rain%' THEN 1 ELSE 0 END) DESC LIMIT 1 | 5,034 | moderate |
bike_share_1 | At what date and time did San Jose Diridon Caltrain Station have most bikes available. | San Jose Diridon Caltrain Station is the name of the station; most bikes available refers to MAX(bikes_available); | SELECT T2.time FROM station AS T1 INNER JOIN status AS T2 ON T2.station_id = T1.id WHERE T1.name = 'San Jose Diridon Caltrain Station' AND T2.bikes_available = ( SELECT MAX(T2.bikes_available) FROM station AS T1 INNER JOIN status AS T2 ON T2.station_id = T1.id WHERE T1.name = 'San Jose Diridon Caltrain Station' ) | 11 | moderate |
bike_share_1 | What is the name of the station that is less used by customers who borrow bikes from? Indicate when was the station installed. | less used station where bikes are borrowed from refers to start_station_name which has the least number of customers; subscription_type = 'Customer'; when installed refers to installation_date; | SELECT T1.start_station_name, T2.installation_date FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.subscription_type = 'Customer' GROUP BY T1.start_station_name ORDER BY COUNT(T1.subscription_type) LIMIT 1 | 866 | moderate |
bike_share_1 | Does the bike with Id number 16 making any intercity trip? If yes, calculate the total travel duration during all the intercity trip. Convert the duration to hour. | intercity trip refers to start_station_name! = end_station_name; total travel duration to hour = DIVIDE(SUM(duration), 3600) AS hour; | SELECT T1.end_station_name, T2.city, CAST(SUM(T1.duration) AS REAL) / 3600 FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.bike_id = 16 AND T1.start_station_name != T1.end_station_name | 4,438 | moderate |
bike_share_1 | Convert all temperature recorded at San Francisco city during August 2013 into degree Celsius. | temperature refers to max_temperature_f; March 2013 refers to date like '3/%/2013'; conversion to Celcius = DIVIDE(SUBTRACT(max_temperature_f, 32), 1.800) as Celsius1; DIVIDE(SUBTRACT(mean_temperature_f, 32), 1.800) as Celsius2; DIVIDE(SUBTRACT(min_temperature_f, 32), 1.800) as Celcius3; | SELECT (max_temperature_f - 32) / 1.8000 , (mean_temperature_f - 32) / 1.8000 , (min_temperature_f - 32) / 1.8000 FROM weather WHERE SUBSTR(CAST(date AS TEXT), 1, INSTR(date, '/') - 1) = '8' AND SUBSTR(CAST(date AS TEXT), -4) = '2013' AND zip_code = 94107 | 5,406 | challenging |
bike_share_1 | How many stations were installed on the date of 8/16/2013 and how many users on those stations are classified as a customer? | installed on refers to installation_date; installation_date = '8/16/2013'; customers refers to subscription_type = customers; | SELECT COUNT(T1.name) , SUM(CASE WHEN T2.subscription_type = 'Customer' THEN 1 ELSE 0 END) FROM station AS T1 INNER JOIN trip AS T2 ON T2.start_station_name = T1.name WHERE T1.installation_date = '8/16/2013' AND T2.subscription_type = 'Customer' | 2,119 | moderate |
bike_share_1 | On 10/20/2014, what is the duration of the fastest trip which started from the station with latitude and longitudes of 37.789625 and -122.400811, respectively? Indicate the bike id. | lat = '37.789625' and long = '-122.400811' are latitude and longitude coordinates indicating location; started from the station refers to start_station_name; start_date = '10/20/2014'; duration of the fastest trip refers to MIN(duration); | SELECT MIN(T2.duration), T2.bike_id FROM station AS T1 INNER JOIN trip AS T2 ON T2.start_station_name = T1.name WHERE T2.start_date LIKE '10/20/2014%' AND T1.lat = 37.789625 AND T1.long = -122.400811 | 1,709 | moderate |
bike_share_1 | How long did it take for bike id 426 to reach 2nd at South Park from Market at 4th on 8/29/2013? Indicate the duration in minutes. | duration in minutes refers to DIVIDE(duration, 60 seconds); 2nd at South Park refers to end_station_name; Market at 4th refers to start_station_name; start_date = '8/29/2013'; end_date = '8/29/2013'; | SELECT CAST(duration AS REAL) / 60 FROM trip WHERE bike_id = 426 AND end_station_name = '2nd at South Park' AND start_station_name = 'Market at 4th' AND start_date LIKE '8/29/2013%' AND end_date LIKE '8/29/2013%' | 3,355 | moderate |
book_publishing_company | Name the publisher which has the most titles published in 1991. | most title published refers to MAX(count(title_id); published in 1991 refers to YEAR(pubdate) = 1991 | SELECT T2.pub_name FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE STRFTIME('%Y', T1.pubdate) = '1991' GROUP BY T1.pub_id, T2.pub_name ORDER BY COUNT(T1.title_id) DESC LIMIT 1 | 3,504 | moderate |
book_publishing_company | For the quantities, what percent more did the store in Fremont sell than the store in Portland in 1993? | qty is abbreviation for quantity; Fremont and Portland are name of city; sell in 1993 refers to YEAR(ord_date) = 1993; percentage = DIVIDE(
SUBTRACT(SUM(qty where city = ‘Fremont’ and year(ord_date = 1993)),
SUM(qty where city = ‘Portland’ and year(ord_date = 1993))), SUM(qty where city = ‘Fremont’ and year(ord_date = 1993)) *100 | SELECT CAST(SUM(CASE WHEN T2.city = 'Fremont' THEN qty END) - SUM(CASE WHEN T2.city = 'Portland' THEN qty END) AS REAL) * 100 / SUM(CASE WHEN T2.city = 'Fremont' THEN qty END) FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id WHERE STRFTIME('%Y', T1.ord_date) = '1993' | 6,349 | challenging |
book_publishing_company | Name the store with ID 7066 and calculate the percentage of the the quantity ordered that were on 'Net 30' payment terms. | store with ID 7066 refers to stor_ID = '7066'; 'Net 60' payment terms refers to payterm = 'Net 60'; qty is abbreviation for quantity; percentage = DIVIDE(payterms = 'Net 60', sum(qty))*100 | SELECT T2.stor_name , CAST(SUM(CASE WHEN payterms = 'Net 30' THEN qty ELSE 0 END) AS REAL) * 100 / SUM(qty) FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id WHERE T1.stor_id = '7066' GROUP BY T2.stor_name | 2,609 | moderate |
book_publishing_company | Among all the employees, how many percent more for the publishers than designers? | publisher and designer are job descriptions which refers to job_desc; percentage more = 100*(SUBTRACT(SUM(CASE WHERE job_desc = 'publisher), SUM(CASE WHERE job_desc = 'designer')) | SELECT CAST(SUM(CASE WHEN T2.job_desc = 'publisher' THEN 1 ELSE 0 END) - SUM(CASE WHEN T2.job_desc = 'designer' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.job_id) FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id | 1,026 | moderate |
book_publishing_company | For all authors from CA who are not on contract, which title of his/hers has the most year to date sales. | year to date sales refers to ytd_sales; on contract refers to contract = 1 | SELECT T1.title FROM titles AS T1 INNER JOIN titleauthor AS T2 ON T1.title_id = T2.title_id INNER JOIN authors AS T3 ON T2.au_id = T3.au_id WHERE T3.contract = 0 AND T3.state = 'CA' ORDER BY T1.ytd_sales DESC LIMIT 1 | 151 | moderate |
book_publishing_company | In the books published by US publishers, which book has the highest royalty? List these books in the descending order of royalty. | US publisher refers publisher in the US where country = 'USA'; | SELECT T1.title FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id INNER JOIN roysched AS T3 ON T1.title_id = T3.title_id WHERE T2.country = 'USA' ORDER BY T1.royalty DESC | 3,428 | moderate |
book_publishing_company | Name the store with the highest quantity in sales? What is the least quantity title from the store's sale? | qty is abbreviation for quantity; highest quantity refers to MAX(qty); least quantity refers to MIN(qty) | SELECT T3.stor_id, T2.title FROM sales AS T1 INNER JOIN titles AS T2 ON T1.title_id = T2.title_id INNER JOIN stores AS T3 ON T3.stor_id = T1.stor_id WHERE T3.stor_id = ( SELECT stor_id FROM sales GROUP BY stor_id ORDER BY SUM(qty) DESC LIMIT 1 ) GROUP BY T3.stor_id, T2.title ORDER BY SUM(T1.qty) ASC LIMIT 1 | 6,262 | challenging |
book_publishing_company | Calculate the percentage of the employees who are Editor or Designer? | Editor or Auditor are job description which refers to job_desc; percentage = DIVIDE(count(job_desc = 'Editor' or job_desc = 'Auditor'), count(emp_id))*100 | SELECT CAST(SUM(CASE WHEN T2.job_desc IN ('Editor', 'Designer') THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.job_id) FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id | 3,238 | moderate |
book_publishing_company | List the type of the book for the order which was sold on 1993/5/29. | sold on refers to ord_date | SELECT DISTINCT T1.type FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id WHERE STRFTIME('%Y-%m-%d', T2.ord_date) = '1993-05-29' | 6,355 | moderate |
book_publishing_company | Which title is about helpful hints on how to use your electronic resources, which publisher published it and what is the price of this book? | publisher refers to pub_name; about the title refers to notes | SELECT T1.title, T2.pub_name, T1.price FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.notes = 'Helpful hints on how to use your electronic resources to the best advantage.' | 591 | moderate |
book_publishing_company | Name the title and publisher for title ID BU 2075. Provide all the royalty percentage for all ranges. | name the publisher refers to pub_name | SELECT T1.title, T3.pub_name, T2.lorange, T2.hirange, T2.royalty FROM titles AS T1 INNER JOIN roysched AS T2 ON T1.title_id = T2.title_id INNER JOIN publishers AS T3 ON T1.pub_id = T3.pub_id WHERE T1.title_id = 'BU2075' | 4,575 | moderate |
book_publishing_company | In 1994 which title had less order quanty than the average order quantity? Find the title name, type and price. | orders in 1994 refers to YEAR(ord_date) = 1994; order quantity refers to number of order expressed by ord_num; average order quantity = DIVIDE(SUM(ord_num), COUNT(title_id)) | SELECT DISTINCT T1.title, T1.type, T1.price FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id WHERE T2.ord_date LIKE '1994%' AND T2.Qty < ( SELECT CAST(SUM(T4.qty) AS REAL) / COUNT(T3.title_id) FROM titles AS T3 INNER JOIN sales AS T4 ON T3.title_id = T4.title_id ) | 1,174 | moderate |
book_publishing_company | Of the titles, which title is about the Carefully researched study of the effects of strong emotions on the body, which state-based publisher published this book, and what is the year-to-date sale? | year to date sales refers to ytd_sales; about the title refers to notes | SELECT T1.title, T2.pub_name, T1.ytd_sales FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.notes = 'Carefully researched study of the effects of strong emotions on the body. Metabolic charts included.' | 4,459 | challenging |
book_publishing_company | Calculate the average level difference between the Marketing editors hired by the US and non-US publishers? | Marketing manager is a job description which refers to job_desc; US publisher refers publisher in the US where country = 'USA'; non-US publishers refers publisher not in the US where country! = 'USA'; job level refers to job_lvl; average level = AVG(job_lvl) | SELECT (CAST(SUM(CASE WHEN T1.country = 'USA' THEN job_lvl ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.country = 'USA' THEN 1 ELSE 0 END)) - (CAST(SUM(CASE WHEN T1.country != 'USA' THEN job_lvl ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.country != 'USA' THEN 1 ELSE 0 END)) FROM publishers AS T1 INNER JOIN employee AS T2 ON T1.pub_id = T2.pub_id INNER JOIN jobs AS T3 ON T2.job_id = T3.job_id WHERE T3.job_desc = 'Managing Editor' | 3,024 | challenging |
book_publishing_company | Name the top five titles that sold more than average and list them in descending order of the number of sales in California stores? | qty is abbreviation for quantity; sold more than average refers to qty > AVG(qty); california refers to state = 'CA" | SELECT T1.title FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id INNER JOIN publishers AS T3 ON T1.pub_id = T3.pub_id WHERE T2.qty > ( SELECT CAST(SUM(qty) AS REAL) / COUNT(title_id) FROM sales ) AND T3.state = 'CA' ORDER BY T2.qty DESC LIMIT 5 | 5,701 | challenging |
book_publishing_company | How many levels are there left for Diego W Roel to reach if he/she could go to the max level for his/her position? | max level for his position refers to max_lvl; job level refers to job_lvl; level left to reach the max = SUBTRACT(max_lvl, job_lvl) | SELECT T2.max_lvl - T1.job_lvl FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T1.fname = 'Diego' AND T1.minit = 'W' AND T1.lname = 'Roel' | 2,523 | moderate |
books | In books published by Ace Book, what is the percentage of English books published? | "Ace Book" is the publisher_name; English book refers to language_name = 'English'; percentage = Divide (Count(book_id where language_name = 'English'), Count(book_id)) * 100 | SELECT CAST(SUM(CASE WHEN T1.language_name = 'English' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM book_language AS T1 INNER JOIN book AS T2 ON T1.language_id = T2.language_id INNER JOIN publisher AS T3 ON T3.publisher_id = T2.publisher_id WHERE T3.publisher_name = 'Ace Book' | 1,891 | challenging |
books | What percentage of books written by Hirohiko make up the number of books published by Viz Media? | "Hirohiko Araki" is the author_name; 'Viz Media' is the publisher_name; percentage = Divide (Count(author_name = 'Hirohiko Araki'), Count(book_id)) * 100 | SELECT CAST(SUM(CASE WHEN T1.author_name = 'Hirohiko Araki' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM author AS T1 INNER JOIN book_author AS T2 ON T2.author_id = T1.author_id INNER JOIN book AS T3 ON T3.book_id = T2.book_id INNER JOIN publisher AS T4 ON T4.publisher_id = T3.publisher_id WHERE T4.publisher_name = 'VIZ Media' | 6,460 | challenging |
books | Calculate the percentage of the International shipping orders on 2022/11/10. | International shipping order refers to method_name = 'International'; orders on 2022/11/10 refers to order_date LIKE '2022-11-10%'; percentage = Divide (Sum(order_id where method_name = 'International'), Count(order_id)) * 100 | SELECT CAST(SUM(CASE WHEN T1.method_name = 'International' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM shipping_method AS T1 INNER JOIN cust_order AS T2 ON T1.method_id = T2.shipping_method_id WHERE T2.order_date LIKE '2022-11-10%' | 6,335 | moderate |
books | Among the books ordered by Lucas Wyldbore, how many of them are over 300 pages? | books have over 300 pages refers to num_pages > 300 | SELECT COUNT(*) FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id INNER JOIN cust_order AS T3 ON T3.order_id = T2.order_id INNER JOIN customer AS T4 ON T4.customer_id = T3.customer_id WHERE T4.first_name = 'Lucas' AND T4.last_name = 'Wyldbore' AND T1.num_pages > 300 | 4,625 | moderate |
books | What is the title of the first book that was written by A.J. Ayer? | "A.J. Ayer" is the author_name; first book refers to Min(publication_date) | SELECT T1.title FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'A.J. Ayer' ORDER BY T1.publication_date ASC LIMIT 1 | 4,506 | moderate |
books | What are the language and title of the ordered books with price less than 20% of the average price of all ordered books? | language refers to language_name; books with price less than 20% of the average price refers to price < Multiply (AVG(price), 0.2) | SELECT DISTINCT T3.language_name, T2.title FROM order_line AS T1 INNER JOIN book AS T2 ON T1.book_id = T2.book_id INNER JOIN book_language AS T3 ON T3.language_id = T2.language_id WHERE T1.price * 100 < ( SELECT AVG(price) FROM order_line ) * 20 | 5,287 | moderate |
books | What is the percentage of books that cost greater than $10 and were ordered by customer Ruthanne Vatini? | cost greater than $10 refers to price > 10; percentage = Divide (Count(book_id where price >10), Count(book_id)) * 100; full name refers to the composition of first name, lastname | SELECT CAST(SUM(CASE WHEN T1.price > 10 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM order_line AS T1 INNER JOIN cust_order AS T2 ON T2.order_id = T1.order_id INNER JOIN customer AS T3 ON T3.customer_id = T2.customer_id WHERE T3.first_name = 'Ruthanne' AND T3.last_name = 'Vatini' | 2,890 | moderate |
books | Please list the titles of all the books that Lucas Wyldbore has ordered. | SELECT T1.title FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id INNER JOIN cust_order AS T3 ON T3.order_id = T2.order_id INNER JOIN customer AS T4 ON T4.customer_id = T3.customer_id WHERE T4.first_name = 'Lucas' AND T4.last_name = 'Wyldbore' | 13 | moderate |
|
books | In books authored by Abraham Lincoln, what is the percentage of the books published in 1992? | "Abraham Lincoln" is the author_name; published in 1992 refers to publication_date LIKE '1992%'; percentage = Divide (Sum(publication_date LIKE '1992%'), Count(publication_date)) * 100 | SELECT CAST(SUM(CASE WHEN STRFTIME('%Y', T1.publication_date) = '1992' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'Abraham Lincoln' | 5,893 | challenging |
books | Write the full name of the customers whose address is at 55 Dorton Pass, Huangqiao. | full name refers to first_name, last_name; '55' is the street_number, 'Dorton Pass' is the street_name; 'Huangqiao' is the city | SELECT DISTINCT T1.first_name, T1.last_name FROM customer AS T1 INNER JOIN customer_address AS T2 ON T1.customer_id = T2.customer_id INNER JOIN address AS T3 ON T3.address_id = T2.address_id WHERE T3.street_number = 55 AND T3.street_name = 'Dorton Pass' AND T3.city = 'Huangqiao' | 4,392 | moderate |
books | List all the titles of the Spanish books published by Alfaguara. | "Spanish" is the language_name; 'Alfaguara' is the publisher_name | SELECT T2.title FROM book_language AS T1 INNER JOIN book AS T2 ON T2.language_id = T1.language_id INNER JOIN publisher AS T3 ON T3.publisher_id = T2.publisher_id WHERE T1.language_name = 'Spanish' AND T3.publisher_name = 'Alfaguara' GROUP BY T2.title | 2,916 | moderate |
books | What is the order price of the book "The Servant Leader" in 2003? | "The Servant Leader" is the title of the book; book in 2003 refers to SUBSTR(publication_date, 1, 4) = '2003' | SELECT T2.price FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id WHERE T1.title = 'The Servant Leader' AND STRFTIME('%Y', T1.publication_date) = '2003' | 135 | moderate |
books | Among the books that were published by Scholastic, how many were written by J.K Rowling? | "J.K Rowling" is the author_name; 'Scholastic' is the publisher_name | SELECT COUNT(*) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id INNER JOIN book_author AS T3 ON T3.book_id = T1.book_id INNER JOIN author AS T4 ON T4.author_id = T3.author_id WHERE T2.publisher_name = 'Scholastic' AND T4.author_name = 'J.K. Rowling' | 2,459 | moderate |
books | Name the title of the book with the most number of pages that was published from 1990 to 2000 by publisher Free Press. | books with the most number of pages refers to Max(num_pages); published from 1990 to 2000 refers to SUBSTR(publication_date, 1, 4) BETWEEN '1990' AND '2000'; 'Free Press' is the publisher_name | SELECT T1.title FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Free Press' AND STRFTIME('%Y', T1.publication_date) BETWEEN '1990' AND '2000' ORDER BY T1.num_pages DESC LIMIT 1 | 5,342 | moderate |
books | Give the publisher's name of the books authored by Alan Lee. | "Alan Lee" is the author_name; publisher's name refers to publisher_name | SELECT T4.publisher_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id INNER JOIN publisher AS T4 ON T4.publisher_id = T1.publisher_id WHERE T3.author_name = 'Alan Lee' GROUP BY T4.publisher_name | 701 | moderate |
books | What is the most common domain for the email address among all the customers? | most common domain for the email refers to Max(Count(SUBSTR(email, CHARINDEX('@', email) + 1, length(email) - charindex('@', email)))) | SELECT SUBSTR(email, INSTR(email, '@') + 1, LENGTH(email) - INSTR(email, '@')) AS ym FROM customer GROUP BY SUBSTR(email, INSTR(email, '@') + 1, LENGTH(email) - INSTR(email, '@')) ORDER BY COUNT(*) DESC LIMIT 1 | 3,274 | moderate |
books | List all the order dates for the customer named "Adrian Kunzelmann". | SELECT T3.order_date FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id INNER JOIN cust_order AS T3 ON T3.order_id = T2.order_id INNER JOIN customer AS T4 ON T4.customer_id = T3.customer_id WHERE T4.first_name = 'Adrian' AND T4.last_name = 'Kunzelmann' | 4,284 | moderate |
|
books | List all the authors who wrote fewer pages than the average. | author refers to author_name; who wrote fewer pages than the average refers to num_pages < AVG(num_pages) | SELECT T3.author_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T1.num_pages < ( SELECT AVG(num_pages) FROM book ) | 6,251 | moderate |
books | How many percent of orders in 2020 used international shipping? | international shipping refers to method_name = 'International'; orders in 2020 refers to order_date = '2020%'; percentage = Divide (Sum(method_name = 'International'), Count(order_id)) * 100 | SELECT CAST(SUM(CASE WHEN T2.method_name = 'International' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM cust_order AS T1 INNER JOIN shipping_method AS T2 ON T1.shipping_method_id = T2.method_id WHERE STRFTIME('%Y', T1.order_date) = '2020' | 4,283 | moderate |
Subsets and Splits