input
stringlengths 236
16.9k
| output
stringlengths 19
805
|
---|---|
-- Database schema
| Air Carriers : Code [ INTEGER ] primary_key , Description [ TEXT ] | Airports : Code [ TEXT ] primary_key , Description [ TEXT ] | Airlines : FL_DATE [ TEXT ] , OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code , TAIL_NUM [ TEXT ] , OP_CARRIER_FL_NUM [ INTEGER ] , ORIGIN_AIRPORT_ID [ INTEGER ] , ORIGIN_AIRPORT_SEQ_ID [ INTEGER ] , ORIGIN_CITY_MARKET_ID [ INTEGER ] , ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code , DEST_AIRPORT_ID [ INTEGER ] , DEST_AIRPORT_SEQ_ID [ INTEGER ] , DEST_CITY_MARKET_ID [ INTEGER ] , DEST [ TEXT ] Airlines.DEST = Airports.Code , CRS_DEP_TIME [ INTEGER ] , DEP_TIME [ INTEGER ] , DEP_DELAY [ INTEGER ] , DEP_DELAY_NEW [ INTEGER ] , ARR_TIME [ INTEGER ] , ARR_DELAY [ INTEGER ] , ARR_DELAY_NEW [ INTEGER ] , CANCELLED [ INTEGER ] , CANCELLATION_CODE [ TEXT ] , CRS_ELAPSED_TIME [ INTEGER ] , ACTUAL_ELAPSED_TIME [ INTEGER ] , CARRIER_DELAY [ INTEGER ] , WEATHER_DELAY [ INTEGER ] , NAS_DELAY [ INTEGER ] , SECURITY_DELAY [ INTEGER ] , LATE_AIRCRAFT_DELAY [ INTEGER ] |
-- -- What are the destinations of the flights with air carrier description "Southeast Alaska Airlines: WEB"?
| SELECT T2.DEST FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T1.Description = 'Southeast Alaska Airlines: WEB'; |
-- Database schema
| Air Carriers : Code [ INTEGER ] primary_key , Description [ TEXT ] | Airports : Code [ TEXT ] primary_key , Description [ TEXT ] | Airlines : FL_DATE [ TEXT ] , OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code , TAIL_NUM [ TEXT ] , OP_CARRIER_FL_NUM [ INTEGER ] , ORIGIN_AIRPORT_ID [ INTEGER ] , ORIGIN_AIRPORT_SEQ_ID [ INTEGER ] , ORIGIN_CITY_MARKET_ID [ INTEGER ] , ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code , DEST_AIRPORT_ID [ INTEGER ] , DEST_AIRPORT_SEQ_ID [ INTEGER ] , DEST_CITY_MARKET_ID [ INTEGER ] , DEST [ TEXT ] Airlines.DEST = Airports.Code , CRS_DEP_TIME [ INTEGER ] , DEP_TIME [ INTEGER ] , DEP_DELAY [ INTEGER ] , DEP_DELAY_NEW [ INTEGER ] , ARR_TIME [ INTEGER ] , ARR_DELAY [ INTEGER ] , ARR_DELAY_NEW [ INTEGER ] , CANCELLED [ INTEGER ] , CANCELLATION_CODE [ TEXT ] , CRS_ELAPSED_TIME [ INTEGER ] , ACTUAL_ELAPSED_TIME [ INTEGER ] , CARRIER_DELAY [ INTEGER ] , WEATHER_DELAY [ INTEGER ] , NAS_DELAY [ INTEGER ] , SECURITY_DELAY [ INTEGER ] , LATE_AIRCRAFT_DELAY [ INTEGER ] |
-- -- From August 10 to August 20, 2018, how many cancelled flights of air carrier named Spirit Air Lines: NK are there?
| SELECT COUNT(*) FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T1.Description = 'Spirit Air Lines: NK' AND T2.CANCELLED = 0 AND T2.FL_DATE BETWEEN '2018/8/10' AND '2018/8/20'; |
-- Database schema
| Air Carriers : Code [ INTEGER ] primary_key , Description [ TEXT ] | Airports : Code [ TEXT ] primary_key , Description [ TEXT ] | Airlines : FL_DATE [ TEXT ] , OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code , TAIL_NUM [ TEXT ] , OP_CARRIER_FL_NUM [ INTEGER ] , ORIGIN_AIRPORT_ID [ INTEGER ] , ORIGIN_AIRPORT_SEQ_ID [ INTEGER ] , ORIGIN_CITY_MARKET_ID [ INTEGER ] , ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code , DEST_AIRPORT_ID [ INTEGER ] , DEST_AIRPORT_SEQ_ID [ INTEGER ] , DEST_CITY_MARKET_ID [ INTEGER ] , DEST [ TEXT ] Airlines.DEST = Airports.Code , CRS_DEP_TIME [ INTEGER ] , DEP_TIME [ INTEGER ] , DEP_DELAY [ INTEGER ] , DEP_DELAY_NEW [ INTEGER ] , ARR_TIME [ INTEGER ] , ARR_DELAY [ INTEGER ] , ARR_DELAY_NEW [ INTEGER ] , CANCELLED [ INTEGER ] , CANCELLATION_CODE [ TEXT ] , CRS_ELAPSED_TIME [ INTEGER ] , ACTUAL_ELAPSED_TIME [ INTEGER ] , CARRIER_DELAY [ INTEGER ] , WEATHER_DELAY [ INTEGER ] , NAS_DELAY [ INTEGER ] , SECURITY_DELAY [ INTEGER ] , LATE_AIRCRAFT_DELAY [ INTEGER ] |
-- -- What is the total number of flights that flew on August 2, 2018 with air carrier described as Horizon Air?
| SELECT COUNT(*) FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T1.Description LIKE '%Horizon Air%' AND T2.FL_DATE = '2018/8/2'; |
-- Database schema
| Air Carriers : Code [ INTEGER ] primary_key , Description [ TEXT ] | Airports : Code [ TEXT ] primary_key , Description [ TEXT ] | Airlines : FL_DATE [ TEXT ] , OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code , TAIL_NUM [ TEXT ] , OP_CARRIER_FL_NUM [ INTEGER ] , ORIGIN_AIRPORT_ID [ INTEGER ] , ORIGIN_AIRPORT_SEQ_ID [ INTEGER ] , ORIGIN_CITY_MARKET_ID [ INTEGER ] , ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code , DEST_AIRPORT_ID [ INTEGER ] , DEST_AIRPORT_SEQ_ID [ INTEGER ] , DEST_CITY_MARKET_ID [ INTEGER ] , DEST [ TEXT ] Airlines.DEST = Airports.Code , CRS_DEP_TIME [ INTEGER ] , DEP_TIME [ INTEGER ] , DEP_DELAY [ INTEGER ] , DEP_DELAY_NEW [ INTEGER ] , ARR_TIME [ INTEGER ] , ARR_DELAY [ INTEGER ] , ARR_DELAY_NEW [ INTEGER ] , CANCELLED [ INTEGER ] , CANCELLATION_CODE [ TEXT ] , CRS_ELAPSED_TIME [ INTEGER ] , ACTUAL_ELAPSED_TIME [ INTEGER ] , CARRIER_DELAY [ INTEGER ] , WEATHER_DELAY [ INTEGER ] , NAS_DELAY [ INTEGER ] , SECURITY_DELAY [ INTEGER ] , LATE_AIRCRAFT_DELAY [ INTEGER ] |
-- -- What is the tail number of the flight with air carrier named Iscargo Hf: ICQ and arrival time of 1000 and below?
| SELECT T2.TAIL_NUM FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T2.ARR_TIME <= 1000 AND T1.Description = 'Iscargo Hf: ICQ'; |
-- Database schema
| Air Carriers : Code [ INTEGER ] primary_key , Description [ TEXT ] | Airports : Code [ TEXT ] primary_key , Description [ TEXT ] | Airlines : FL_DATE [ TEXT ] , OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code , TAIL_NUM [ TEXT ] , OP_CARRIER_FL_NUM [ INTEGER ] , ORIGIN_AIRPORT_ID [ INTEGER ] , ORIGIN_AIRPORT_SEQ_ID [ INTEGER ] , ORIGIN_CITY_MARKET_ID [ INTEGER ] , ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code , DEST_AIRPORT_ID [ INTEGER ] , DEST_AIRPORT_SEQ_ID [ INTEGER ] , DEST_CITY_MARKET_ID [ INTEGER ] , DEST [ TEXT ] Airlines.DEST = Airports.Code , CRS_DEP_TIME [ INTEGER ] , DEP_TIME [ INTEGER ] , DEP_DELAY [ INTEGER ] , DEP_DELAY_NEW [ INTEGER ] , ARR_TIME [ INTEGER ] , ARR_DELAY [ INTEGER ] , ARR_DELAY_NEW [ INTEGER ] , CANCELLED [ INTEGER ] , CANCELLATION_CODE [ TEXT ] , CRS_ELAPSED_TIME [ INTEGER ] , ACTUAL_ELAPSED_TIME [ INTEGER ] , CARRIER_DELAY [ INTEGER ] , WEATHER_DELAY [ INTEGER ] , NAS_DELAY [ INTEGER ] , SECURITY_DELAY [ INTEGER ] , LATE_AIRCRAFT_DELAY [ INTEGER ] |
-- -- List the flight date of flights with air carrier described as Profit Airlines Inc.: XBH which have an actual elapsed time below 100.
| SELECT T2.FL_DATE FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T2.ACTUAL_ELAPSED_TIME < 100 AND T1.Description = 'Profit Airlines Inc.: XBH'; |
-- Database schema
| Air Carriers : Code [ INTEGER ] primary_key , Description [ TEXT ] | Airports : Code [ TEXT ] primary_key , Description [ TEXT ] | Airlines : FL_DATE [ TEXT ] , OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code , TAIL_NUM [ TEXT ] , OP_CARRIER_FL_NUM [ INTEGER ] , ORIGIN_AIRPORT_ID [ INTEGER ] , ORIGIN_AIRPORT_SEQ_ID [ INTEGER ] , ORIGIN_CITY_MARKET_ID [ INTEGER ] , ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code , DEST_AIRPORT_ID [ INTEGER ] , DEST_AIRPORT_SEQ_ID [ INTEGER ] , DEST_CITY_MARKET_ID [ INTEGER ] , DEST [ TEXT ] Airlines.DEST = Airports.Code , CRS_DEP_TIME [ INTEGER ] , DEP_TIME [ INTEGER ] , DEP_DELAY [ INTEGER ] , DEP_DELAY_NEW [ INTEGER ] , ARR_TIME [ INTEGER ] , ARR_DELAY [ INTEGER ] , ARR_DELAY_NEW [ INTEGER ] , CANCELLED [ INTEGER ] , CANCELLATION_CODE [ TEXT ] , CRS_ELAPSED_TIME [ INTEGER ] , ACTUAL_ELAPSED_TIME [ INTEGER ] , CARRIER_DELAY [ INTEGER ] , WEATHER_DELAY [ INTEGER ] , NAS_DELAY [ INTEGER ] , SECURITY_DELAY [ INTEGER ] , LATE_AIRCRAFT_DELAY [ INTEGER ] |
-- -- Among the flights with air carrier named Republic Airline, how many of the flights have departure delay of 30 minutes and above?
| SELECT COUNT(*) FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T1.Description LIKE '%Republic Airline%' AND T2.DEP_DELAY > 30; |
-- Database schema
| Air Carriers : Code [ INTEGER ] primary_key , Description [ TEXT ] | Airports : Code [ TEXT ] primary_key , Description [ TEXT ] | Airlines : FL_DATE [ TEXT ] , OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code , TAIL_NUM [ TEXT ] , OP_CARRIER_FL_NUM [ INTEGER ] , ORIGIN_AIRPORT_ID [ INTEGER ] , ORIGIN_AIRPORT_SEQ_ID [ INTEGER ] , ORIGIN_CITY_MARKET_ID [ INTEGER ] , ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code , DEST_AIRPORT_ID [ INTEGER ] , DEST_AIRPORT_SEQ_ID [ INTEGER ] , DEST_CITY_MARKET_ID [ INTEGER ] , DEST [ TEXT ] Airlines.DEST = Airports.Code , CRS_DEP_TIME [ INTEGER ] , DEP_TIME [ INTEGER ] , DEP_DELAY [ INTEGER ] , DEP_DELAY_NEW [ INTEGER ] , ARR_TIME [ INTEGER ] , ARR_DELAY [ INTEGER ] , ARR_DELAY_NEW [ INTEGER ] , CANCELLED [ INTEGER ] , CANCELLATION_CODE [ TEXT ] , CRS_ELAPSED_TIME [ INTEGER ] , ACTUAL_ELAPSED_TIME [ INTEGER ] , CARRIER_DELAY [ INTEGER ] , WEATHER_DELAY [ INTEGER ] , NAS_DELAY [ INTEGER ] , SECURITY_DELAY [ INTEGER ] , LATE_AIRCRAFT_DELAY [ INTEGER ] |
-- -- What are the air carriers of the flights that flew on August 25, 2018 that have departure delay of -5?
| SELECT T1.Description FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T2.FL_DATE = '2018/8/25' GROUP BY T1.Description; |
-- Database schema
| Air Carriers : Code [ INTEGER ] primary_key , Description [ TEXT ] | Airports : Code [ TEXT ] primary_key , Description [ TEXT ] | Airlines : FL_DATE [ TEXT ] , OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code , TAIL_NUM [ TEXT ] , OP_CARRIER_FL_NUM [ INTEGER ] , ORIGIN_AIRPORT_ID [ INTEGER ] , ORIGIN_AIRPORT_SEQ_ID [ INTEGER ] , ORIGIN_CITY_MARKET_ID [ INTEGER ] , ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code , DEST_AIRPORT_ID [ INTEGER ] , DEST_AIRPORT_SEQ_ID [ INTEGER ] , DEST_CITY_MARKET_ID [ INTEGER ] , DEST [ TEXT ] Airlines.DEST = Airports.Code , CRS_DEP_TIME [ INTEGER ] , DEP_TIME [ INTEGER ] , DEP_DELAY [ INTEGER ] , DEP_DELAY_NEW [ INTEGER ] , ARR_TIME [ INTEGER ] , ARR_DELAY [ INTEGER ] , ARR_DELAY_NEW [ INTEGER ] , CANCELLED [ INTEGER ] , CANCELLATION_CODE [ TEXT ] , CRS_ELAPSED_TIME [ INTEGER ] , ACTUAL_ELAPSED_TIME [ INTEGER ] , CARRIER_DELAY [ INTEGER ] , WEATHER_DELAY [ INTEGER ] , NAS_DELAY [ INTEGER ] , SECURITY_DELAY [ INTEGER ] , LATE_AIRCRAFT_DELAY [ INTEGER ] |
-- -- Provide the air carrier description of the flight with a tail number N922US from Phoenix.
| SELECT T2.Description FROM Airlines AS T1 INNER JOIN `Air Carriers` AS T2 ON T2.Code = T1.OP_CARRIER_AIRLINE_ID WHERE T1.TAIL_NUM = 'N922US' AND T1.ORIGIN = 'PHX' GROUP BY T2.Description; |
-- Database schema
| Air Carriers : Code [ INTEGER ] primary_key , Description [ TEXT ] | Airports : Code [ TEXT ] primary_key , Description [ TEXT ] | Airlines : FL_DATE [ TEXT ] , OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code , TAIL_NUM [ TEXT ] , OP_CARRIER_FL_NUM [ INTEGER ] , ORIGIN_AIRPORT_ID [ INTEGER ] , ORIGIN_AIRPORT_SEQ_ID [ INTEGER ] , ORIGIN_CITY_MARKET_ID [ INTEGER ] , ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code , DEST_AIRPORT_ID [ INTEGER ] , DEST_AIRPORT_SEQ_ID [ INTEGER ] , DEST_CITY_MARKET_ID [ INTEGER ] , DEST [ TEXT ] Airlines.DEST = Airports.Code , CRS_DEP_TIME [ INTEGER ] , DEP_TIME [ INTEGER ] , DEP_DELAY [ INTEGER ] , DEP_DELAY_NEW [ INTEGER ] , ARR_TIME [ INTEGER ] , ARR_DELAY [ INTEGER ] , ARR_DELAY_NEW [ INTEGER ] , CANCELLED [ INTEGER ] , CANCELLATION_CODE [ TEXT ] , CRS_ELAPSED_TIME [ INTEGER ] , ACTUAL_ELAPSED_TIME [ INTEGER ] , CARRIER_DELAY [ INTEGER ] , WEATHER_DELAY [ INTEGER ] , NAS_DELAY [ INTEGER ] , SECURITY_DELAY [ INTEGER ] , LATE_AIRCRAFT_DELAY [ INTEGER ] |
-- -- Give the air carrier description of the flights that have an earlier arrival and departure.
| SELECT T1.Description FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T2.ARR_DELAY < 0 AND T2.DEP_DELAY < 0 GROUP BY T1.Description; |
-- Database schema
| Air Carriers : Code [ INTEGER ] primary_key , Description [ TEXT ] | Airports : Code [ TEXT ] primary_key , Description [ TEXT ] | Airlines : FL_DATE [ TEXT ] , OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code , TAIL_NUM [ TEXT ] , OP_CARRIER_FL_NUM [ INTEGER ] , ORIGIN_AIRPORT_ID [ INTEGER ] , ORIGIN_AIRPORT_SEQ_ID [ INTEGER ] , ORIGIN_CITY_MARKET_ID [ INTEGER ] , ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code , DEST_AIRPORT_ID [ INTEGER ] , DEST_AIRPORT_SEQ_ID [ INTEGER ] , DEST_CITY_MARKET_ID [ INTEGER ] , DEST [ TEXT ] Airlines.DEST = Airports.Code , CRS_DEP_TIME [ INTEGER ] , DEP_TIME [ INTEGER ] , DEP_DELAY [ INTEGER ] , DEP_DELAY_NEW [ INTEGER ] , ARR_TIME [ INTEGER ] , ARR_DELAY [ INTEGER ] , ARR_DELAY_NEW [ INTEGER ] , CANCELLED [ INTEGER ] , CANCELLATION_CODE [ TEXT ] , CRS_ELAPSED_TIME [ INTEGER ] , ACTUAL_ELAPSED_TIME [ INTEGER ] , CARRIER_DELAY [ INTEGER ] , WEATHER_DELAY [ INTEGER ] , NAS_DELAY [ INTEGER ] , SECURITY_DELAY [ INTEGER ] , LATE_AIRCRAFT_DELAY [ INTEGER ] |
-- -- Among the flights with air carrier "Southwest Airlines Co.: WN", provide the tail number of flights with an actual elapsed time lower than the 80% of the average actual elapsed time of listed flights.
| SELECT T2.TAIL_NUM FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T1.Description = 'Southwest Airlines Co.: WN' AND T2.ACTUAL_ELAPSED_TIME < ( SELECT AVG(ACTUAL_ELAPSED_TIME) * 0.8 FROM Airlines ); |
-- Database schema
| Air Carriers : Code [ INTEGER ] primary_key , Description [ TEXT ] | Airports : Code [ TEXT ] primary_key , Description [ TEXT ] | Airlines : FL_DATE [ TEXT ] , OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code , TAIL_NUM [ TEXT ] , OP_CARRIER_FL_NUM [ INTEGER ] , ORIGIN_AIRPORT_ID [ INTEGER ] , ORIGIN_AIRPORT_SEQ_ID [ INTEGER ] , ORIGIN_CITY_MARKET_ID [ INTEGER ] , ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code , DEST_AIRPORT_ID [ INTEGER ] , DEST_AIRPORT_SEQ_ID [ INTEGER ] , DEST_CITY_MARKET_ID [ INTEGER ] , DEST [ TEXT ] Airlines.DEST = Airports.Code , CRS_DEP_TIME [ INTEGER ] , DEP_TIME [ INTEGER ] , DEP_DELAY [ INTEGER ] , DEP_DELAY_NEW [ INTEGER ] , ARR_TIME [ INTEGER ] , ARR_DELAY [ INTEGER ] , ARR_DELAY_NEW [ INTEGER ] , CANCELLED [ INTEGER ] , CANCELLATION_CODE [ TEXT ] , CRS_ELAPSED_TIME [ INTEGER ] , ACTUAL_ELAPSED_TIME [ INTEGER ] , CARRIER_DELAY [ INTEGER ] , WEATHER_DELAY [ INTEGER ] , NAS_DELAY [ INTEGER ] , SECURITY_DELAY [ INTEGER ] , LATE_AIRCRAFT_DELAY [ INTEGER ] |
-- -- List the air carrier's description with arrival time lower than the 40% of the average arrival time of flights that flew to Phoenix.
| SELECT T1.Description FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T2.DEST = 'PHX' AND T2.ARR_TIME < ( SELECT AVG(ARR_TIME) * 0.4 FROM Airlines ) GROUP BY T1.Description; |
-- Database schema
| Air Carriers : Code [ INTEGER ] primary_key , Description [ TEXT ] | Airports : Code [ TEXT ] primary_key , Description [ TEXT ] | Airlines : FL_DATE [ TEXT ] , OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code , TAIL_NUM [ TEXT ] , OP_CARRIER_FL_NUM [ INTEGER ] , ORIGIN_AIRPORT_ID [ INTEGER ] , ORIGIN_AIRPORT_SEQ_ID [ INTEGER ] , ORIGIN_CITY_MARKET_ID [ INTEGER ] , ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code , DEST_AIRPORT_ID [ INTEGER ] , DEST_AIRPORT_SEQ_ID [ INTEGER ] , DEST_CITY_MARKET_ID [ INTEGER ] , DEST [ TEXT ] Airlines.DEST = Airports.Code , CRS_DEP_TIME [ INTEGER ] , DEP_TIME [ INTEGER ] , DEP_DELAY [ INTEGER ] , DEP_DELAY_NEW [ INTEGER ] , ARR_TIME [ INTEGER ] , ARR_DELAY [ INTEGER ] , ARR_DELAY_NEW [ INTEGER ] , CANCELLED [ INTEGER ] , CANCELLATION_CODE [ TEXT ] , CRS_ELAPSED_TIME [ INTEGER ] , ACTUAL_ELAPSED_TIME [ INTEGER ] , CARRIER_DELAY [ INTEGER ] , WEATHER_DELAY [ INTEGER ] , NAS_DELAY [ INTEGER ] , SECURITY_DELAY [ INTEGER ] , LATE_AIRCRAFT_DELAY [ INTEGER ] |
-- -- Among the flights of the air carrier described as American Airlines, what is the percentage of the flights with earlier departure?
| SELECT CAST(SUM(CASE WHEN T2.DEP_DELAY < 0 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T1.Description LIKE '%American Airlines%'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Among the books published by publisher ID 1929, how many of them have over 500 pages?
| SELECT COUNT(*) FROM book WHERE publisher_id = 1929 AND num_pages > 500; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the publication date of the book with the most pages?
| SELECT publication_date FROM book ORDER BY num_pages DESC LIMIT 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the name of the publisher of the book "The Illuminati"?
| SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T1.title = 'The Illuminati'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- How many books were published by publisher "Thomas Nelson"?
| SELECT COUNT(*) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Thomas Nelson'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the name of the publisher that has published the most number of books?
| SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id GROUP BY T2.publisher_name ORDER BY COUNT(T1.book_id) DESC LIMIT 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Please give the title of the oldest book published by publisher "Thomas Nelson".
| SELECT T1.title FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Thomas Nelson' ORDER BY T1.publication_date ASC LIMIT 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Among the books published by publisher "Thomas Nelson", how many of them have over 300 pages?
| SELECT COUNT(*) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Thomas Nelson' AND T1.num_pages > 300; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the name of the publisher of the book with the most pages?
| SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id ORDER BY T1.num_pages DESC LIMIT 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- How many books are in English?
| SELECT COUNT(*) FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id WHERE T2.language_name = 'English'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Please list the titles of all the books in British English.
| SELECT T1.title FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id WHERE T2.language_name = 'British English'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the cheapest order price of the book "The Little House"?
| SELECT MIN(T2.price) FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id WHERE T1.title = 'The Little House'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- 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'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Among the books ordered by Lucas Wyldbore, how many of them are over 300 pages?
| 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; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the total price of all the books ordered by Lucas Wyldbore?
| SELECT SUM(T1.price) 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 = 'Lucas' AND T3.last_name = 'Wyldbore'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- How much money on average does Lucas Wyldbore spend on book orders?
| SELECT SUM(T1.price) / 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 = 'Lucas' AND T3.last_name = 'Wyldbore'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Among the books ordered by Lucas Wyldbore, what is the percentage of those books over $13?
| SELECT CAST(SUM(CASE WHEN T1.price > 13 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 = 'Lucas' AND T3.last_name = 'Wyldbore'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Which city does the address id 547 belong to?
| SELECT city FROM address WHERE address_id = 547; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- How many orders has Cordy Dumbarton made?
| SELECT COUNT(*) FROM customer AS T1 INNER JOIN cust_order AS T2 ON T1.customer_id = T2.customer_id WHERE T1.first_name = 'Cordy' AND T1.last_name = 'Dumbarton'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- List the title of the earliest published Japanese book.
| SELECT T1.title FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id WHERE T2.language_name = 'Japanese' ORDER BY T1.publication_date ASC LIMIT 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- For the publisher which published the most books, show its name.
| SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id GROUP BY T2.publisher_name ORDER BY COUNT(T2.publisher_id) DESC LIMIT 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- How many books were published by Kensington?
| SELECT COUNT(T1.book_id) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Kensington'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Which language was book id 1405 written in?
| SELECT T2.language_name FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id WHERE T1.book_id = 1405; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Which customer has made the most orders? Show his/her full name.
| SELECT T1.first_name, T1.last_name FROM customer AS T1 INNER JOIN cust_order AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.first_name, T1.last_name ORDER BY COUNT(*) DESC LIMIT 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Name the book title of the bestseller.
| SELECT T1.title FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id GROUP BY T1.title ORDER BY COUNT(T1.title) DESC LIMIT 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- How many books did David Foster Wallace write?
| SELECT COUNT(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 = 'David Foster Wallace'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- How many orders does the book "O Xará" have?
| SELECT COUNT(*) FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id WHERE T1.title = 'O Xará'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Which country does Malina Johnson live in?
| SELECT T4.country_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 INNER JOIN country AS T4 ON T4.country_id = T3.country_id WHERE T1.first_name = 'Malina' AND T1.last_name = 'Johnson' AND T2.status_id = 2; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Give the number of Ukrainian addresses in the database.
| SELECT COUNT(*) FROM country AS T1 INNER JOIN address AS T2 ON T1.country_id = T2.country_id WHERE T1.country_name = 'Ukraine'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Which country does Žirovnica city belong to?
| SELECT T1.country_name FROM country AS T1 INNER JOIN address AS T2 ON T1.country_id = T2.country_id WHERE T2.city = 'Žirovnica'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Calculate the percentage of the International shipping orders on 2022/11/10.
| 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%'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the average number of pages of David Coward's books?
| SELECT AVG(T1.num_pages) 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 = 'David Coward'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the cost of the slowest and least expensive shipping method?
| SELECT method_name FROM shipping_method ORDER BY cost ASC LIMIT 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the title of the first book that was published in 1900?
| SELECT title FROM book WHERE STRFTIME('%Y', publication_date) = '1900' ORDER BY publication_date LIMIT 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the full name of the customer who owns the "[email protected]" e-mail address?
| SELECT first_name, last_name FROM customer WHERE email = '[email protected]'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- How many orders in 2022 have Iran as their destinations?
| SELECT COUNT(*) FROM country AS T1 INNER JOIN address AS T2 ON T1.country_id = T2.country_id INNER JOIN cust_order AS T3 ON T3.dest_address_id = T2.address_id WHERE T1.country_name = 'Iran' AND STRFTIME('%Y', T3.order_date) = '2022'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Among Daisey Lamball's orders, how many were shipped via International shipping?
| SELECT COUNT(*) FROM customer AS T1 INNER JOIN cust_order AS T2 ON T1.customer_id = T2.customer_id INNER JOIN shipping_method AS T3 ON T3.method_id = T2.shipping_method_id WHERE T1.first_name = 'Daisey' AND T1.last_name = 'Lamball' AND T3.method_name = 'International'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the full name of the customer who ordered the most books of all time?
| SELECT T1.first_name, T1.last_name FROM customer AS T1 INNER JOIN cust_order AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.first_name, T1.last_name ORDER BY COUNT(*) DESC LIMIT 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- How many orders did Antonia Poltun return?
| SELECT COUNT(*) FROM order_status AS T1 INNER JOIN order_history AS T2 ON T1.status_id = T2.status_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 T1.status_value = 'Returned' AND T4.first_name = 'Antonia' AND T4.last_name = 'Poltun'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Which shipping method is preferred by customers the most?
| SELECT T2.method_name FROM cust_order AS T1 INNER JOIN shipping_method AS T2 ON T1.shipping_method_id = T2.method_id GROUP BY T2.method_name ORDER BY COUNT(T2.method_id) DESC LIMIT 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- How many orders were delivered in 2021?
| SELECT COUNT(*) FROM order_status AS T1 INNER JOIN order_history AS T2 ON T1.status_id = T2.status_id WHERE T1.status_value = 'Delivered' AND STRFTIME('%Y', T2.status_date) = '2021'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the name of the first book written by J.K Rowling?
| 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 = 'J.K. Rowling' ORDER BY T1.publication_date ASC LIMIT 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- How many books did A.R. Braunmuller write?
| SELECT COUNT(*) FROM author AS T1 INNER JOIN book_author AS T2 ON T1.author_id = T2.author_id WHERE T1.author_name = 'A.R. Braunmuller'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the name of the publisher who published Agatha Christie's first book?
| 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 = 'Agatha Christie' ORDER BY T1.publication_date ASC LIMIT 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- List all the names of the books written by Danielle Steel.
| 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 = 'Danielle Steel'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- How many books by William Shakespeare were published by Penguin Classics?
| SELECT 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 INNER JOIN publisher AS T4 ON T4.publisher_id = T1.publisher_id WHERE T3.author_name = 'William Shakespeare' AND T4.publisher_name = 'Penguin Classics'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the name of the publisher that published the most books?
| SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id GROUP BY T2.publisher_name ORDER BY COUNT(T2.publisher_id) DESC LIMIT 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the total shipping cost of all the orders made by Page Holsey? Indicate how many of the said orders were ordered in 2022.
| SELECT SUM(T3.cost) FROM customer AS T1 INNER JOIN cust_order AS T2 ON T1.customer_id = T2.customer_id INNER JOIN shipping_method AS T3 ON T3.method_id = T2.shipping_method_id WHERE T1.first_name = 'Page' AND T1.last_name = 'Holsey' AND STRFTIME('%Y', T2.order_date) = '2022'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the name of the publisher with publisher ID 22?
| SELECT publisher_name FROM publisher WHERE publisher_id = 22; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- How many of the books authored by Al Gore have less than 400 pages?
| SELECT 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 = 'Al Gore' AND T1.num_pages < 400; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- List the author's and publisher's name of the book published on July 10, 1997.
| SELECT T3.author_name, 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 T1.publication_date = '1997-07-10'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the language of the book with ISBN 23755004321?
| SELECT T2.language_name FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id WHERE T1.isbn13 = 23755004321; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the title of the most expensive book?
| SELECT T1.title FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id ORDER BY T2.price DESC LIMIT 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Calculate the total price of books ordered by customer named Lucas Wyldbore.
| SELECT SUM(T1.price) 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 = 'Lucas' AND T3.last_name = 'Wyldbore'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- List the ISBN of the book published in Spanish.
| SELECT T1.isbn13 FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id WHERE T2.language_name = 'Spanish'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Among the books that cost less than 1 dollar, how many were published by Berkley Trade?
| SELECT COUNT(*) FROM publisher AS T1 INNER JOIN book AS T2 ON T1.publisher_id = T2.publisher_id INNER JOIN order_line AS T3 ON T3.book_id = T2.book_id WHERE T1.publisher_name = 'Berkley' AND T3.price < 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- List the title of the books purchased by the customer named Zia Roizin.
| 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 = 'Zia' AND T4.last_name = 'Roizin'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Who authored the book with greatest number of 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 ORDER BY T1.num_pages DESC LIMIT 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- List the email of customers that bought the book titled Switch on the Night.
| SELECT T4.email 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 T1.title = 'Switch on the Night'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- List the author's name of the books published by Abrams.
| 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 INNER JOIN publisher AS T4 ON T4.publisher_id = T1.publisher_id WHERE T4.publisher_name = 'Abrams'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the publisher name of the book titled The Illuminati?
| SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T1.title = 'The Illuminati'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- In books authored by Abraham Lincoln, what is the percentage of the books published in 1992?
| 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'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Among the books published in 2004, list the name of the publisher of books with number of pages greater than 70% of the average number of pages of all books.
| SELECT T1.title, T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE STRFTIME('%Y', T1.publication_date) = '2004' AND T1.num_pages * 100 > ( SELECT AVG(num_pages) FROM book ) * 70; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Provide the contact email of Moss Zarb.
| SELECT email FROM customer WHERE first_name = 'Moss' AND last_name = 'Zarb'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Name the streets in Dallas.
| SELECT street_name FROM address WHERE city = 'Dallas'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Which books were released by Orson Scott Card in 2001?
| 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 = 'Orson Scott Card' AND STRFTIME('%Y', T1.publication_date) = '2001'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Count the number of books written by Orson Scott Card.
| SELECT 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 = 'Orson Scott Card'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Provide the authors and titles of the books which have more than 3000 pages.
| SELECT T3.author_name, 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 T1.num_pages > 3000; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Who wrote "The Prophet"?
| 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.title = 'The Prophet'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- How many books were published by Ace Hardcover?
| SELECT COUNT(*) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Ace Hardcover'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Which publisher published Barry Eisler's book?
| 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 = 'Barry Eisler'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- How many books were published in Japanese?
| SELECT COUNT(T2.book_id) FROM book_language AS T1 INNER JOIN book AS T2 ON T1.language_id = T2.language_id WHERE T1.language_name = 'Japanese'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Sum the total price of the orders for The Prophet book.
| SELECT SUM(T1.price) FROM order_line AS T1 INNER JOIN book AS T2 ON T1.book_id = T2.book_id WHERE T2.title = 'The Prophet'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Provide the number of orders by Daisey Lamball in 2021.
| SELECT COUNT(*) FROM cust_order AS T1 INNER JOIN customer AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = 'Daisey' AND T2.last_name = 'Lamball' AND STRFTIME('%Y', T1.order_date) = '2021'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- How many customers are from Australia?
| SELECT COUNT(*) FROM customer_address AS T1 INNER JOIN address AS T2 ON T2.address_id = T1.address_id INNER JOIN country AS T3 ON T3.country_id = T2.country_id WHERE T3.country_name = 'Australia'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- How many orders were delivered in December 2019?
| SELECT COUNT(*) FROM order_status AS T1 INNER JOIN order_history AS T2 ON T1.status_id = T2.status_id WHERE T1.status_value = 'Delivered' AND STRFTIME('%Y', T2.status_date) = '2019'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Provide the customers' names who ordered the Fantasmas.
| SELECT T4.first_name, T4.last_name 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 T1.title = 'Fantasmas'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- How many percent of orders in 2020 used international shipping?
| 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'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- List all the authors named "George".
| SELECT author_name FROM author WHERE author_name LIKE 'George%'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Which year has the most customer orders?
| SELECT strftime('%Y', order_date) FROM cust_order GROUP BY strftime('%Y', order_date) ORDER BY COUNT(strftime('%Y', order_date)) DESC LIMIT 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the average price for the order line?
| SELECT AVG(price) FROM order_line; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- List all of the books that were published in 1995.
| SELECT title FROM book WHERE STRFTIME('%Y', publication_date) = '1995'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What is the most common domain for the email address among all the customers?
| 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; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- How many publishers have the word "book" in their name?
| SELECT COUNT(*) FROM publisher WHERE publisher_name LIKE '%book%'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Which language is the rarest among all the books?
| SELECT T2.language_name FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id GROUP BY T2.language_name ORDER BY COUNT(T2.language_name) ASC LIMIT 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- 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'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- How many addresses are from the Philippines?
| SELECT COUNT(T2.country_id) FROM address AS T1 INNER JOIN country AS T2 ON T2.country_id = T1.country_id WHERE T2.country_name = 'Philippines'; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- Who is the author who wrote the most books?
| SELECT T1.author_name FROM author AS T1 INNER JOIN book_author AS T2 ON T1.author_id = T2.author_id GROUP BY T1.author_name ORDER BY COUNT(T2.author_id) DESC LIMIT 1; |
-- Database schema
| address_status : status_id [ INTEGER ] primary_key , address_status [ TEXT ] | author : author_id [ INTEGER ] primary_key , author_name [ TEXT ] | book_language : language_id [ INTEGER ] primary_key , language_code [ TEXT ] , language_name [ TEXT ] | country : country_id [ INTEGER ] primary_key , country_name [ TEXT ] | address : address_id [ INTEGER ] primary_key , street_number [ TEXT ] , street_name [ TEXT ] , city [ TEXT ] , country_id [ INTEGER ] address.country_id = country.country_id | customer : customer_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] | customer_address : customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id , address_id [ INTEGER ] customer_address.address_id = address.address_id , status_id [ INTEGER ] | order_status : status_id [ INTEGER ] primary_key , status_value [ TEXT ] | publisher : publisher_id [ INTEGER ] primary_key , publisher_name [ TEXT ] | book : book_id [ INTEGER ] primary_key , title [ TEXT ] , isbn13 [ TEXT ] , language_id [ INTEGER ] book.language_id = book_language.language_id , num_pages [ INTEGER ] , publication_date [ DATE ] , publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id | book_author : book_id [ INTEGER ] book_author.book_id = book.book_id , author_id [ INTEGER ] book_author.author_id = author.author_id | shipping_method : method_id [ INTEGER ] primary_key , method_name [ TEXT ] , cost [ REAL ] | cust_order : order_id [ INTEGER ] primary_key , order_date [ DATETIME ] , customer_id [ INTEGER ] , shipping_method_id [ INTEGER ] , dest_address_id [ INTEGER ] | order_history : history_id [ INTEGER ] primary_key , order_id [ INTEGER ] , status_id [ INTEGER ] , status_date [ DATETIME ] | order_line : line_id [ INTEGER ] primary_key , order_id [ INTEGER ] , book_id [ INTEGER ] , price [ REAL ] |
-- -- What are the books published by "Harper Collins"?
| SELECT T1.title FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Harper Collins'; |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.