db_id stringclasses 68 values | question stringlengths 24 325 | evidence stringlengths 0 580 | SQL stringlengths 23 728 |
|---|---|---|---|
food_inspection_2 | Among the establishments that paid a 500 fine, what is the percentage of restaurants? | a 500 fine refers to fine = 500; restaurant refers to facility_type = 'Restaurant'; percentage = divide(count(license_no where facility_type = 'Restaurant'), count(license_no)) * 100% where fine = 500 | SELECT CAST(COUNT(CASE WHEN T1.facility_type = 'Restaurant' THEN T1.license_no END) AS REAL) * 100 / COUNT(T1.facility_type) FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no INNER JOIN violation AS T3 ON T2.inspection_id = T3.inspection_id WHERE T3.fine = 500 |
coinmarketcap | What is the total value of Argentum coined traded in the past 24 hours on 2016/10/11. | total value in the past 24 hours refers to volume_24h; on 11/10/16 refers to date = '2016-11-10' | SELECT T2.volume_24h FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'Argentum' AND T2.date = '2016-10-11' |
coinmarketcap | List the price for Zetacoin on 13/11/1 and the next 7 consecutive days. What is the average price for these 7 days? | on 1/11/13 and the next 7 consecutive days refers to DATE BETWEEN '2013-11-01' AND '2013-11-07'; average price refers to AVG(price); Zetacoin refers to name = 'Zetacoin' | SELECT T2.price FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'Zetacoin' AND T2.date BETWEEN '2013-11-01' AND '2013-11-07' UNION ALL SELECT AVG(T2.PRICE) FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'Zetacoin' AND T2.date BETWEEN '2013-11-01' AND '2013-11-07' |
coinmarketcap | State the transaction date whereby DigixDAO was transacted at the hightest price. | the highest price refers to max(price); DigixDAO refers to name = 'DigixDAO' | SELECT T2.date FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'DigixDAO' ORDER BY T2.price DESC LIMIT 1 |
coinmarketcap | Name the coin with the highest percentage price changed in 24 hours. State the transaction date and price. | the highest percentage price changed in 24 hours refers to max(percent_change_24h) | SELECT T1.name, T2.DATE, T2.price FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.percent_change_24h = ( SELECT MAX(percent_change_24h) FROM historical ) |
coinmarketcap | State the transaction date and the price when Bitcoin was bottomed? | was bottomed refers to min(price) | SELECT T2.date, T2.price FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'Bitcoin' ORDER BY T2.price LIMIT 1 |
coinmarketcap | Name the coin and date of transactions with the greatest decline in percent change in 1 hour. | the greatest decline in percent change in 1 hour refers to max(percent_change_1h) | SELECT T1.name, T2.date FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.percent_change_1h = ( SELECT MIN(percent_change_1h) FROM historical ) |
coinmarketcap | Name the coin under the token category that gives the highest max profit. | the highest max profit refers to max(subtract(high, low)) | SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.category = 'token' ORDER BY T2.high - T2.low DESC LIMIT 1 |
coinmarketcap | Which crytocurrency was ranked the first by CoinMarketCap on 2013/4/28? | ranked the first refers to cmc_rank = 1; on 2013/4/28 refers to date = '2013-04-28' | SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2013-04-28' AND T2.cmc_rank = 1 |
coinmarketcap | How much dollars was a Bitcoin worth on 2013/4/28 according to the coin market? | worth refers to price; on 2013/4/28 refers to date = '2013-04-28' | SELECT T2.market_cap FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2013-04-28' AND T1.name = 'Bitcoin' |
coinmarketcap | Which crytocurrency was not opened on 2013/5/3? | not opened refers to open IS NULL; on 2013/5/3 refers to date = '2013-05-03' | SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2013-05-03' AND T2.open IS NULL |
coinmarketcap | What was the price of Bitcoin when it closed at the end of the day on 2013/4/29? | price when it closed refers to close; on 2013/4/29 refers to date = '2013-04-29' | SELECT T2.close FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2013-04-29' AND T1.name = 'Bitcoin' |
coinmarketcap | When did Bitcoin reach its highest price on 2013/4/29? | time that a coin reaches its highest price refers to time_high; on 2013/4/29 refers to date = '2013-04-29' | SELECT T2.time_high FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2013-04-29' AND T1.name = 'Bitcoin' |
coinmarketcap | What was the number of Bitcoins verifiably burned until 2013/4/28? | the number of Bitcoins verifiably burned = max_supply - total_supply; 2013/4/28 refers to date = '2013-04-28' | SELECT T2.max_supply - T2.total_supply FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2013-04-28' AND T1.name = 'Bitcoin' |
coinmarketcap | Which crytocurrency was traded in the highest value on 2016/1/8? | traded in the highest value refers to max(volume_24h); on 2016/1/8 refers to date = '2016-01-08' | SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2016-01-08' AND T2.volume_24h = ( SELECT MAX(volume_24h) FROM historical WHERE date = '2016-01-08' ) |
coinmarketcap | Please list the names of the crytocurrencies that have a total amount of existence of over 10000000 on 2013/4/28. | a total amount of existence of over 10000000 refers to total_supply>10000000; on 2013/4/28 refers to date = '2013-04-28' | SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2013-04-28' AND T2.total_supply > 10000000 |
coinmarketcap | Had Bitcoin's price increased or decreased on 2013/5/5 compared with the price 7 days before? | price increased refers to percent_change_7d>0; decreased refers percent_change_7d<0; on 2013/5/5 refers to date = '2013-05-05' | SELECT (CASE WHEN T2.percent_change_7d > 0 THEN 'INCREASED' ELSE 'DECREASED' END) FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2013-05-05' AND T1.name = 'Bitcoin' |
coinmarketcap | Which crytocurrency had a bigger number of coins circulating in the market and in the general public's hands on 2013/4/28, Bitcoin or Litecoin? | a bigger number of coins circulating in the market refers to max(circulating_supply); on 2013/4/28 refers to date = '2013-04-28' | SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2013-04-28' AND T1.name IN ('Bitcoin', 'Litecoin') ORDER BY T2.circulating_supply DESC LIMIT 1 |
coinmarketcap | How much was a Bitcoin on 2013/4/28? | how much refers to price; on 2013/4/28 refers to date = '2013-04-28' | SELECT T2.price FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2013-04-28' AND T1.name = 'Bitcoin' |
coinmarketcap | What was the percentage of the Bitcoins verifiably burned until 2018/4/28? | the percentage of the Bitcoins verifiably burned = divide(subtract(SUM(max_supply), SUM(total_supply)),SUM(total_supply))*100%; until 2013/4/28 refers to date<'2013-04-08' | SELECT CAST((SUM(T2.max_supply) - SUM(T2.total_supply)) AS REAL) / SUM(T2.total_supply) FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date < '2018-04-28' AND T1.name = 'Bitcoin' |
coinmarketcap | Please list the names of coins that has been disappeared. | has disappeared refers to status = 'extinct' | SELECT name FROM coins WHERE status = 'extinct' |
coinmarketcap | What's the descripition of BitBar? | SELECT description FROM coins WHERE name = 'BitBar' | |
coinmarketcap | List the names and symbols of the coins that were added on June 14, 2013. | added on June 14, 2013 refers to date_added like '2013-06-14%' | SELECT name, symbol FROM coins WHERE date_added LIKE '2013-06-14%' |
coinmarketcap | List the names of coins that cannot be traded in 2014. | cannot be tracked refers to status = 'untracked'; in 2014 refers to year(date_added) = '2014' | SELECT name FROM coins WHERE date_added LIKE '2014%' AND status = 'untracked' |
coinmarketcap | Name the coins that have three tags. | have three tags refers to length(tag_names)-length(replace(tag_names,',','')) = 2 | SELECT name FROM coins WHERE LENGTH(tag_names) - LENGTH(replace(tag_names, ',', '')) = 2 |
coinmarketcap | What is the name of the coin with the highest price? | the highest price refers to max(price) | SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.price = ( SELECT MAX(price) FROM historical ) |
coinmarketcap | Please name the coin that ranked first among the coins traded on April 29, 2013. | ranked first refers to cmc_rank = 1; on April 29, 2013 refers to date = '2013-04-29' | SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2013-04-29' AND T2.cmc_rank = 1 |
coinmarketcap | When is the best time to purchase Bitcoin? | lowest price refers to low; best time refers to date with the low; | SELECT T2.date FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'Bitcoin' ORDER BY T2.low LIMIT 1 |
coinmarketcap | What is the name of the coin that creates the most total value in the past 24 hours? | creates the most total value in the past 24 hours refers to max(volume_24h) | SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.volume_24h = ( SELECT MAX(volume_24h) FROM historical ) |
coinmarketcap | When is the highest closed price of CHNCoin? | the highest closed price refers to max(close) | SELECT T2.date FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'CHNCoin' ORDER BY T2.close DESC LIMIT 1 |
coinmarketcap | When did Peercoin rank fifth? | when refers to date; rank fifth refers to cmc_rank = 5 | SELECT T2.date FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'Peercoin' AND T2.cmc_rank = 5 |
coinmarketcap | When is Devcoin most valuable in the market? | when refers to date; most valuable refers to max(market_cap) | SELECT T2.date FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'Devcoin' ORDER BY T2.market_cap DESC LIMIT 1 |
coinmarketcap | List the names of the top five coins traded on January 1, 2014. | the top five coins refers to cmc_rank< = 5; on January 1, 2014 refers to date = '2014-01-01' | SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2014-01-01' AND T2.cmc_rank <= 5 |
coinmarketcap | When was Lebowskis not opened? | when refers to date; not opened refers to open IS NULL | SELECT DISTINCT T2.date FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'Lebowskis' AND (T2.open IS NULL OR T2.open = 0) |
coinmarketcap | When is the highest price of Terracoin? | when refers to date; the highest price refers to max(price) | SELECT T2.date FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T1.name = 'Terracoin' ORDER BY T2.price DESC LIMIT 1 |
coinmarketcap | List the names of the coins above the average price on April 28, 2013. | average price = divide(sum(price), count(name)); on April 28, 2013 refers to date = '2013-04-28' | SELECT T1.name FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2018-04-28' AND T2.price > ( SELECT AVG(price) FROM historical WHERE date = '2018-04-28' ) |
coinmarketcap | What's the percentage of coins that is higher than the price 1 hour ago in May 29,2013? List the names of these coins. | percentage that is higher than the price 1 hour ago refers to percent_change_1h>0; in May 29,2013 refers to date = '2013-05-29' | SELECT T1.NAME FROM coins AS T1 INNER JOIN historical AS T2 ON T1.ID = T2.coin_id WHERE T2.DATE = '2013-05-29' AND T2.percent_change_1h > 0 |
retail_world | Please list the names of all the products whose supplier is in Japan. | names of the products refers to ProductName; Japan refers to Country = 'Japan'; | SELECT T1.ProductName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.Country = 'Japan' |
retail_world | Give the full name of the youngest employee. | full name = FirstName, LastName; youngest refers to latest BirthDate; | SELECT FirstName, LastName FROM Employees WHERE BirthDate = ( SELECT MAX(BirthDate) FROM Employees ) |
retail_world | Provide the number of orders that were handled by Michael Suyama. | SELECT COUNT(T2.OrderID) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.FirstName = 'Michael' AND T1.LastName = 'Suyama' | |
retail_world | How many kinds of products are there in the the category of "dairy products"? | kinds of products refers to ProductID; category refers to CategoryName; | SELECT COUNT(T1.ProductID) FROM Products AS T1 INNER JOIN Categories AS T2 ON T1.CategoryID = T2.CategoryID WHERE T2.CategoryName = 'Dairy Products' |
retail_world | Which category does "tofu" belong to? | category refers to CategoryName; tofu refers to ProductName = 'Tofu'; | SELECT T2.CategoryName FROM Products AS T1 INNER JOIN Categories AS T2 ON T1.CategoryID = T2.CategoryID WHERE T1.ProductName = 'Tofu' |
retail_world | Give the contact name of the supplier for the product "Gudbrandsdalsost". | product refers to ProductName | SELECT T2.ContactName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.ProductName = 'Gudbrandsdalsost' |
retail_world | Tell the country name of the supplier for "Scottish Longbreads". | "Scottish Longbreads" refers to ProductName = 'Scottish Longbreads' | SELECT T2.Country FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.ProductName = 'Scottish Longbreads' |
retail_world | How many customers are there in the country with the highest number of customers? | highest number refers to max(count(CustomerID)) | SELECT COUNT(CustomerID) FROM Customers GROUP BY Country ORDER BY COUNT(CustomerID) DESC LIMIT 1 |
retail_world | How many suppliers are there in the United States of America? | United States of America refers to Country = 'USA' | SELECT COUNT(SupplierID) FROM Suppliers WHERE Country = 'USA' |
retail_world | What is the name of the supplier that supplies the most products to the company? | name of the supplier refers to SupplierID; the most product refers to max(count(ProductID)) | SELECT T1.SupplierID FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID GROUP BY T1.SupplierID ORDER BY COUNT(*) DESC LIMIT 1 |
retail_world | What is the full name of the employee who handled the highest amount of orders? | full name refers to FirstName LastName; highest amount of orders refers to max(count(OrderID)) | SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID GROUP BY T1.FirstName, T1.LastName ORDER BY COUNT(*) DESC LIMIT 1 |
retail_world | What is the name of the contact person of the Pavlova supplier company? | contact person refers to ContactName; Pavlova is the name of the product; | SELECT T2.ContactName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.ProductName = 'Pavlova' |
retail_world | What are the products that belong to the beverage category? | products belong to beverage category refer to ProductName where CategoryName = 'beverage'; | SELECT T2.ProductName FROM Categories AS T1 INNER JOIN Products AS T2 ON T1.CategoryID = T2.CategoryID WHERE T1.CategoryName = 'Beverages' |
retail_world | Who is the person to contact to get Camembert Pierrot? | Camembert Pierrot is the name of the product; person to contact refers to ContactName; | SELECT T2.ContactName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.ProductName = 'Camembert Pierrot' |
retail_world | List down the customer ids who placed order with Michael Suyama. | SELECT T2.CustomerID FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.FirstName = 'Michael' AND T1.LastName = 'Suyama' | |
retail_world | How many orders have Margaret Peacock placed? | SELECT COUNT(T2.EmployeeID) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.FirstName = 'Margaret' AND T1.LastName = 'Peacock' | |
retail_world | Calculate the total products that are supplied by Japan suppliers. | Japan Supplier refers to Country = 'Japan'; total product refers to Count (ProductName) | SELECT COUNT(T1.SupplierID) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.Country = 'Japan' |
retail_world | What is the contact name for product Teatime Chocolate Biscuits? | "Teatime Chocolate Biscuits" is the ProductName | SELECT T2.ContactName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.ProductName = 'Teatime Chocolate Biscuits' |
retail_world | How many customers are there in Berlin, Germany? | "Berlin" is the City; 'Germany' is the Country | SELECT COUNT(City) FROM Customers WHERE Country = 'Germany' AND City = 'Berlin' |
retail_world | Which country are the majority of the suppliers located? | majority of the suppliers located refers to MAX(COUNT(SupplierID)) | SELECT Country FROM Suppliers GROUP BY Country ORDER BY COUNT(SupplierID) DESC LIMIT 1 |
retail_world | What are the ID and description of the condiments category? | condiments category refers to CategoryName = 'Condiments'; the ID refers to CategoryID | SELECT CategoryID, Description FROM Categories WHERE CategoryName = 'Condiments' |
retail_world | What were the products supplied by the company in Spain? | company in Spain refers to Country = 'Spain'; product supplied refers to ProductName | SELECT T1.ProductName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.Country = 'Spain' |
retail_world | How many orders were made by the customers in Ireland. | in Ireland refers to Country = 'Ireland'; | SELECT COUNT(T2.OrderID) FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Country = 'Ireland' |
retail_world | Provide the full name of the employee who processed the sales order with ID 10274. | full name refers to FirstName, LastName; sales order with ID 10274 refers to OrderID = 10274 | SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.OrderID = 10274 |
retail_world | How many suppliers does Northwind have in USA? | 'USA' is a country; supplier refers to CompanyName | SELECT COUNT(SupplierID) FROM Suppliers WHERE Country = 'USA' |
retail_world | How many companies do ship Northwind's orders? | companies refers to ShipperID | SELECT COUNT(ShipperID) FROM Shippers |
retail_world | Indicate category name of soft drinks, coffees, teas, beers, and ales in description list. | Soft drinks, coffees, teas, beers, and ales' is Description of CategoryName | SELECT CategoryName FROM Categories WHERE Description = 'Soft drinks, coffees, teas, beers, and ales' |
retail_world | List all product names under Confections. | 'Confections' is a CompanyName; | SELECT T1.ProductName FROM Products AS T1 INNER JOIN Categories AS T2 ON T1.CategoryID = T2.CategoryID WHERE T2.CategoryName = 'Confections' |
retail_world | Name the products where the suppliers come from Finland. | 'Finland' is a Country; product refers to ProductName; suppliers refers to SupplierID | SELECT T1.ProductName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.Country = 'Finland' |
retail_world | The product 'Mozzarella di Giovanni' belongs in which category? Include the category's description as well. | Mozzarella di Giovanni' is a ProductName; category refers to CategoryName; | SELECT T2.CategoryName, T2.Description FROM Products AS T1 INNER JOIN Categories AS T2 ON T1.CategoryID = T2.CategoryID WHERE T1.ProductName = 'Mozzarella di Giovanni' |
retail_world | How many suppliers are from UK? | from UK refers to Country = 'UK' | SELECT COUNT(SupplierID) FROM Suppliers WHERE Country = 'UK' |
retail_world | What is the name of product with the ID of 77? | name of product refers to ProductName; ID refers to ProductID | SELECT ProductName FROM Products WHERE ProductID = 77 |
retail_world | How many orders were handled by Michael Suyama. State the order ID. | SELECT COUNT(T2.OrderID) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.FirstName = 'Michael' AND T1.LastName = 'Suyama' | |
retail_world | How many customers are located in London? | London refers to City = 'London' | SELECT COUNT(CustomerID) FROM Customers WHERE City = 'London' |
retail_world | List out the full name of employee who has birth day on "3/4/1955 12:00:00 AM". | full name refers to FirstName, LastName; brith day refers to BirthDate | SELECT FirstName, LastName FROM Employees WHERE BirthDate = '1955-03-04 00:00:00' |
retail_world | Mention the first name of employee who took care the order id 10250. | SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.OrderID = 10250 | |
retail_world | Give the full name of employee who handled the order id 10280. | full name refers to FirstName, LastName | SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.OrderID = 10280 |
retails | How many kinds of items are returned in order no.5? | returned refer to l_returnflag = 'R'; order no.5 refers to l_orderkey = 5; kinds of items refer to l_linenumber; | SELECT COUNT(l_linenumber) FROM lineitem WHERE l_orderkey = 5 AND l_returnflag = 'R' |
retails | When was the latest date the items of order no.1 were shipped? | order no.1 refers to l_orderkey = 1; the latest date shipped refers to MAX(l_shipdate); | SELECT MAX(l_shipdate) FROM lineitem WHERE l_orderkey = 1 |
retails | Which order has a higher priority, order no. 4 or order no. 36? | earlier orderdate have higher priority in delivery; which order no. 4 or order no. 36 refers to o_orderkey in (4, 36) where MIN(o_orderdate); | SELECT l_orderkey FROM lineitem WHERE l_orderkey IN (4, 36) ORDER BY l_shipdate DESC LIMIT 1 |
retails | What is the comment of the order with the highest total price? | the highest total price refers to MAX(o_totalprice); comment of the order refers to o_comment; | SELECT o_comment FROM orders WHERE o_totalprice = ( SELECT MAX(o_totalprice) FROM orders ) |
retails | What is the phone number of Customer#000000001? | customer phone refers to c_phone; Customer#000000001 refers to c_name; | SELECT c_phone FROM customer WHERE c_name = 'Customer#000000001' |
retails | How many orders in total have the customers in the household segment made? | orders in household segment refer to o_orderkey where c_mktsegment = 'HOUSEHOLD'; | SELECT COUNT(T1.o_orderkey) FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T2.c_mktsegment = 'HOUSEHOLD' |
retails | Among all the orders made by a customer in the household segment, what is the highest total price? | orders in household segment refer to o_orderkey where c_mktsegment = 'HOUSEHOLD'; the highest total price refers to MAX(o_totalprice); | SELECT MAX(T1.o_totalprice) FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T2.c_mktsegment = 'HOUSEHOLD' |
retails | Please list the order comments of all the orders made by customers in the household segment. | orders in household segment refer to o_orderkey where c_mktsegment = 'HOUSEHOLD'; order comments refer to o_comment; | SELECT T1.o_comment FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T2.c_mktsegment = 'HOUSEHOLD' |
retails | Please give the name of the customer who has made the single order with the highest total price. | name of the customer refers to c_name; single order with the highest total price refers to MAX(o_totalprice) LIMIT 1; | SELECT T2.c_name FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey ORDER BY T1.o_totalprice DESC LIMIT 1 |
retails | Please list the order keys of all the orders made by a customer whose account is in debt. | account is in debt if c_acctbal < 0; | SELECT T1.o_orderkey FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T2.c_acctbal < 0 |
retails | Among the orders made by customers in the household segment, how many of them are urgent? | orders in household segment refer to o_orderkey where c_mktsegment = 'HOUSEHOLD'; the order is urgent if o_orderpriority = '1-URGENT' ; | SELECT COUNT(T1.o_orderpriority) FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T2.c_mktsegment = 'HOUSEHOLD' AND T1.o_orderpriority = '1-URGENT' |
retails | How many customers are in Brazil? | Brazil is the name of the nation which refers to n_name = 'BRAZIL' | SELECT COUNT(T1.c_custkey) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T2.n_name = 'BRAZIL' |
retails | Please list the phone numbers of all the customers in the household segment and are in Brazil. | phone numbers refer to c_phone; Brazil is the name of the nation which refers to n_name = 'BRAZIL'; household segment refers to c_mktsegment = 'HOUSEHOLD'; | SELECT T1.c_phone FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T1.c_mktsegment = 'HOUSEHOLD' AND T2.n_name = 'BRAZIL' |
retails | Among all the customers in Germany, how many of them have an account balance of over 1000? | Germany is the name of the nation which refers to n_name = 'GERMANY'; account balance of over 1000 refers to c_acctbal > 1000; | SELECT COUNT(T1.c_custkey) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T2.n_name = 'GERMANY' AND T1.c_acctbal > 1000 |
retails | How many orders in total are made by customers in Germany? | orders refer to o_orderkey; Germany is the name of the nation which refers to n_name = 'GERMANY'; | SELECT COUNT(T2.c_custkey) FROM nation AS T1 INNER JOIN customer AS T2 ON T1.n_nationkey = T2.c_nationkey INNER JOIN orders AS T3 ON T2.c_custkey = T3.o_custkey WHERE T1.n_name = 'GERMANY' |
retails | What is the total price of all the orders made by customers in Germany? | orders refer to o_orderkey; total price refers to o_totalprice; Germany is the name of the nation which refers to n_name = 'GERMANY'; | SELECT SUM(T3.o_totalprice) FROM nation AS T1 INNER JOIN customer AS T2 ON T1.n_nationkey = T2.c_nationkey INNER JOIN orders AS T3 ON T2.c_custkey = T3.o_custkey WHERE T1.n_name = 'GERMANY' |
retails | Among the orders made by customers in Germany, which one of them has the highest priority in delivery? Please give its order key. | orders refer to o_orderkey; Germany is the name of the nation which refers to n_name = 'GERMANY'; earlier orderdate have higher priority in delivery therefore MIN(o_orderdate); | SELECT T3.o_orderkey FROM nation AS T1 INNER JOIN customer AS T2 ON T1.n_nationkey = T2.c_nationkey INNER JOIN orders AS T3 ON T2.c_custkey = T3.o_custkey WHERE T1.n_name = 'GERMANY' ORDER BY T3.o_orderdate LIMIT 1 |
retails | What is the average price of the orders made by a customer in Germany? | DIVIDE(SUM(o_totalprice), COUNT(o_orderkey)) where n_name = 'GERMANY'; | SELECT AVG(T3.o_totalprice) FROM nation AS T1 INNER JOIN customer AS T2 ON T1.n_nationkey = T2.c_nationkey INNER JOIN orders AS T3 ON T2.c_custkey = T3.o_custkey WHERE T1.n_name = 'GERMANY' |
retails | How many countries are there in the No.2 region? | No.2 region refers to n_regionkey = 2; | SELECT COUNT(n_nationkey) FROM nation WHERE n_regionkey = 2 |
retails | Which country does supplier No.34 come from? | supplier No.34 refers to s_suppkey = 34; country refers to n_name; | SELECT T2.n_name FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey WHERE T1.s_suppkey = 34 |
retails | Which region does "Supplier#000000129" belong to? | "Supplier#000000129" is the name of the supplier which refers to s_name; Which region refers to r_name; | SELECT T3.r_name FROM nation AS T1 INNER JOIN supplier AS T2 ON T1.n_nationkey = T2.s_nationkey INNER JOIN region AS T3 ON T1.n_regionkey = T3.r_regionkey WHERE T2.s_name = 'Supplier#000000129' |
retails | What is the nationality of "Customer#000000055"? | "Customer#000000055" is the name of the customer which refers to c_name; nationality is the state of belonging to a particular country, therefore nationality refers to n_name; | SELECT T2.n_name FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_name = 'Customer#000000055' |
retails | Give customer No.106936's region name. | "Customer#000000055" is the name of the customer which refers to c_name; region name refers to r_name; | SELECT T3.r_name FROM nation AS T1 INNER JOIN customer AS T2 ON T1.n_nationkey = T2.c_nationkey INNER JOIN region AS T3 ON T1.n_regionkey = T3.r_regionkey WHERE T2.c_custkey = 106936 |
retails | Give the number of Moroccan customers whose account is in debt. | account is in debt if c_acctbal < 0; Moroccan customers refer to c_name WHERE n_name = 'MOROCCO'; | SELECT COUNT(T1.c_name) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T2.n_name = 'MOROCCO' AND T1.c_acctbal < 0 |
retails | Give the name of the customer who made an order with Clerk#000000803 on 1997/12/10. | name of the customer refers to c_name; o_clerk = 'Clerk#000000803'; order on 1997/12/10 refers to o_orderdate = '1997-12-10'; | SELECT T2.c_name FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T1.o_orderdate = '1997-12-10' AND T1.o_clerk = 'Clerk#000000803' |
retails | Calculates the profit processed by Supplier No. 7414 on order No. 817154. | SUBTRACT(MULTIPLY(l_extendedprice, (SUBTRACT(1, l_discount)), MULTIPLY(ps_supplycost, l_quantity))) WHERE l_suppkey = 7414 AND l_orderkey = 817154; | SELECT T1.l_extendedprice * (1 - T1.l_discount) - T2.ps_supplycost * T1.l_quantity FROM lineitem AS T1 INNER JOIN partsupp AS T2 ON T1.l_suppkey = T2.ps_suppkey WHERE T1.l_suppkey = 7414 AND T1.l_orderkey = 817154 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.