Chinastark/bird_dataset huggingface dataset:
Database: car_retails
Note: reportsto' is the leader of the 'employeenumber';
Question: How many customers have an employee who reports to William Patterson as their sales representitive?
SQL: SELECT count(customers.customernumber) FROM customers INNER JOIN employees ON customers.salesrepemployeenumber = employees.employeenumber WHERE employees.firstname = 'William' AND employees.lastname = 'Patterson'
Database: car_retails
Question: Please list the phone numbers of the top 3 customers that have the highest credit limit and have Leslie Jennings as their sales representitive.
SQL: SELECT customers.phone FROM customers INNER JOIN employees ON customers.salesrepemployeenumber = employees.employeenumber WHERE employees.firstname = 'Leslie' AND employees.lastname = 'Jennings' ORDER BY customers.creditlimit DESC LIMIT 3
Database: car_retails
Note: Sales representative refers to jobtitle = 'Sales Rep'; country = 'USA';
Question: How many sales representitives are based in the offices in the USA?
SQL: SELECT count(employees.employeenumber) FROM employees INNER JOIN offices ON employees.officecode = offices.officecode WHERE offices.country = 'USA' AND employees.jobtitle = 'Sales Rep'
Database: car_retails
Note: Where can I find the office refers to address, comprising of addressline1 and addressline2; President is a jobtitle;
Question: Where can I find the office of the President of the company?
SQL: SELECT offices.addressline1, offices.addressline2 FROM employees INNER JOIN offices ON employees.officecode = offices.officecode WHERE employees.jobtitle = 'President'
Database: car_retails
Note: VP Sales refers to jobtitle;
Question: What's the postal code of the office the VP Sales is at?
SQL: SELECT offices.postalcode FROM employees INNER JOIN offices ON employees.officecode = offices.officecode WHERE employees.jobtitle = 'VP Sales'
Database: car_retails
Note: SUM(MULTIPLY(quantityordered, priceeach)) where orderdate = '2003-03-03'; customername = 'Cruz & Sons Co.';
Question: What is the total price of the order made by Cruz & Sons Co. on 2003/3/3?
SQL: SELECT sum(orderdetails.priceeach * orderdetails.quantityordered) FROM orderdetails INNER JOIN orders ON orderdetails.ordernumber = orders.ordernumber INNER JOIN customers ON orders.customernumber = customers.customernumber WHERE customers.customername = 'Cruz & Sons Co.' AND orders.orderdate = '2003-03-03'
Database: car_retails
Note: Cruz & Sons Co. is name of customer; 2003/3/3 refers to orderdate;
Question: Which product did Cruz & Sons Co. order on 2003/3/3?
SQL: SELECT products.productname FROM orderdetails INNER JOIN orders ON orderdetails.ordernumber = orders.ordernumber INNER JOIN customers ON orders.customernumber = customers.customernumber INNER JOIN products ON orderdetails.productcode = products.productcode WHERE customers.customername = 'Cruz & Sons Co.' AND orders.orderdate = '2003-03-03'
Database: car_retails
Note: Cruz & Sons Co. is name of customer; the biggest amount refers to MAX(quantityordered).;
Question: Which product did Cruz & Sons Co. ask for the biggest amount in a single order?
SQL: SELECT products.productname FROM orderdetails INNER JOIN orders ON orderdetails.ordernumber = orders.ordernumber INNER JOIN customers ON orders.customernumber = customers.customernumber INNER JOIN products ON orderdetails.productcode = products.productcode WHERE customers.customername = 'Cruz & Sons Co.' ORDER BY orderdetails.priceeach * orderdetails.quantityordered DESC LIMIT 1
Database: car_retails
Note: Cruz & Sons Co. is name of customer; ordered on 2003-03-03 refers to orderdate;
Question: When were the products ordered by Cruz & Sons Co. on 2003-03-03 shipped?
SQL: SELECT orders.shippeddate FROM orders INNER JOIN customers ON orders.customernumber = customers.customernumber WHERE customers.customername = 'Cruz & Sons Co.' AND orders.orderdate = '2003-03-03'
Database: car_retails
Question: What is the amount of customers of 1957 Chevy Pickup by customers in a month?
SQL: SELECT count(orders.customernumber) FROM orderdetails INNER JOIN orders ON orderdetails.ordernumber = orders.ordernumber WHERE orderdetails.productcode IN ( SELECT productcode FROM products WHERE productname = '1957 Chevy Pickup' )
Database: car_retails
Note: The greatest expected profit refers to MAX(SUBTRACT(msrp, buyprice);
Question: Name the product from the 'Classic Cars' production line that has the greatest expected profit.
SQL: SELECT t.productname, t.msrp - t.buyprice FROM products AS t WHERE t.productline = 'Classic Cars' ORDER BY t.msrp - t.buyprice DESC LIMIT 1
Database: car_retails
Note: Still processing refers to status = 'In Process';
Question: List all the name of customers who have orders that are still processing.
SQL: SELECT customers.customername FROM orders INNER JOIN customers ON orders.customernumber = customers.customernumber WHERE orders.status = 'In Process'
Database: car_retails
Note: orders shipped refer to status = 'Shipped'; at least 3 days before the required date refers to SUBTRACT(shippeddate, requireddate)>3; DIVIDE(COUNT(ordernumber where SUBTRACT(shippeddate, requireddate)>3), (COUNT(ordernumber) as percentage;
Question: Among all orders shipped, calculate the percentage of orders shipped at least 3 days before the required date.
SQL: SELECT count(CASE WHEN julianday(orders.shippeddate) - julianday(orders.requireddate) > 3 THEN orders.customernumber ELSE NULL END) FROM orders INNER JOIN orderdetails ON orders.ordernumber = orderdetails.ordernumber WHERE orders.status = 'Shipped'
Database: car_retails
Note: The highest payment refers to max(amount); 2005 refers to year(paymentdate);
Question: Find the customer who made the highest payment in 2005.
SQL: SELECT customers.customername FROM payments INNER JOIN customers ON payments.customernumber = customers.customernumber WHERE strftime('%Y', payments.paymentdate) = '2005' GROUP BY customers.customernumber, customers.customername ORDER BY sum(payments.amount) DESC LIMIT 1
Database: car_retails
Note: The most ordered quantity product refers to productname where Max(quantityordered); SUBTRACT(msrp, buyprice);
Question: Which is the most ordered quantity product? What is its expected profit margin per piece?
SQL: SELECT productname, msrp - buyprice FROM products WHERE productcode = ( SELECT productcode FROM orderdetails ORDER BY quantityordered DESC LIMIT 1 )
Database: car_retails
Note: The largest order in terms of total price refers to MAX(SUM(MULTIPLY(quantityordered, priceeach)).;
Question: For the order has the most product ordered, name the customer who placed the order.
SQL: SELECT employees.firstname, employees.lastname FROM offices INNER JOIN employees ON offices.officecode = employees.officecode WHERE employees.employeenumber = ( SELECT max(employeenumber) FROM employees )
Database: car_retails
Note: orders that are disputed refer to status = 'Disputed'; the sales representative means employees; names refers to firstname, lastname.;
Question: List all customer names with orders that are disputed.
SQL: SELECT employees.firstname, employees.lastname FROM orders INNER JOIN customers ON orders.customernumber = customers.customernumber INNER JOIN employees ON customers.salesrepemployeenumber = employees.employeenumber WHERE orders.status = 'Disputed'
Database: car_retails
Note: DIVIDE(COUNT(employeenumber) when city = 'Paris'), (COUNT(employeenumber)) as percentage;
Question: What is the percentage of employees are in Paris office?
SQL: SELECT cast(count(CASE WHEN offices.city = 'Paris' THEN employees.employeenumber ELSE NULL END) AS REAL) * 100 / count(employees.employeenumber) FROM offices INNER JOIN employees ON offices.officecode = employees.officecode
Database: car_retails
Note: Sales Manager refers to jobtitle; Europe, Middle East, and Africa region refers to territory = 'EMEA';
Question: Name the Sales Manager of Europe, Middle East, and Africa region. In which office does he/she report to?
SQL: SELECT employees.firstname, employees.lastname FROM offices INNER JOIN employees ON offices.officecode = employees.officecode WHERE employees.jobtitle = 'Sale Manager (EMEA)'
Database: car_retails
Note: Japan is the name of the country; 'reportsto' is the leader of the 'employeenumber';
Question: List the name of employees in Japan office and who are they reporting to.
SQL: SELECT employees.firstname, employees.lastname, employees.reportsto FROM offices INNER JOIN employees ON offices.officecode = employees.officecode WHERE offices.country = 'Japan'
Database: car_retails
Note: 1939 'Chevrolet Deluxe Coupe' refers to productname; the highest price refers to MAX(priceeach);
Question: Which customer ordered 1939 'Chevrolet Deluxe Coupe' at the highest price?
SQL: SELECT customers.customername FROM products INNER JOIN orderdetails ON products.productcode = orderdetails.productcode INNER JOIN orders ON orderdetails.ordernumber = orders.ordernumber INNER JOIN customers ON orders.customernumber = customers.customernumber WHERE products.productname = '1939 Chevrolet Deluxe Coupe' ORDER BY orderdetails.priceeach DESC LIMIT 1
Database: car_retails
Note: DIVIDE(SUM(amount) where customername = 'Atelier graphique'), (SUM(amount)) as percentage where year(paymentdate) = 2004;
Question: What is the percentage of the payment amount in 2004 was made by Atelier graphique?
SQL: SELECT sum(CASE WHEN customers.customername = 'Atelier graphique' THEN payments.amount ELSE 0 END) * 100 / sum(payments.amount) FROM customers INNER JOIN payments ON customers.customernumber = payments.customernumber WHERE strftime('%Y', payments.paymentdate) = '2004'
Database: car_retails
Note: SUM(MULTIPLY(quantityordered (SUBTRACT (priceeach, buyprice));
Question: Calculate the actual profit for order number 10100.
SQL: SELECT sum((orderdetails.priceeach - products.buyprice) * orderdetails.quantityordered) FROM orderdetails INNER JOIN products ON orderdetails.productcode = products.productcode WHERE orderdetails.ordernumber = '10100'
Database: car_retails
Note: Pay in total refers to SUM(amount);
Question: How much did customer 103 pay in total?
SQL: SELECT sum(t.amount) FROM payments t WHERE t.customernumber = '103'
Database: car_retails
Note: SUM(MULTIPLY(quantityordered, priceeach);
Question: What is the total price of the order 10100?
SQL: SELECT sum(t.priceeach * t.quantityordered) FROM orderdetails t WHERE t.ordernumber = '10100'
Database: car_retails
Note: The highest unit price refers to MAX(priceeach);
Question: Please list the top three product names with the highest unit price.
SQL: SELECT products.productname FROM products INNER JOIN orderdetails ON products.productcode = orderdetails.productcode ORDER BY orderdetails.priceeach DESC LIMIT 3
Database: car_retails
Note: Employee 1370 refers to employeenumber = '1370';
Question: Among the customers of empolyee 1370, who has the highest credit limit?Please list the full name of the contact person.
SQL: SELECT customers.contactfirstname, customers.contactlastname FROM employees INNER JOIN customers ON employees.employeenumber = customers.salesrepemployeenumber WHERE employees.employeenumber = '1370' ORDER BY customers.creditlimit DESC LIMIT 1
Database: car_retails
Note: 2003 Harley-Davidson Eagle Drag Bikes refers to productname; how many ordered refers to COUNT(quantityordered);
Question: How many 2003 Harley-Davidson Eagle Drag Bikes were ordered?
SQL: SELECT sum(orderdetails.quantityordered) FROM products INNER JOIN orderdetails ON products.productcode = orderdetails.productcode WHERE products.productname = '2003 Harley-Davidson Eagle Drag Bike'
Database: car_retails
Note: The highest unit price refers to MAX(priceeach); when shipped refers to shippeddate;
Question: When was the product with the highest unit price shipped?
SQL: SELECT orders.shippeddate FROM orders INNER JOIN orderdetails ON orders.ordernumber = orderdetails.ordernumber ORDER BY orderdetails.priceeach DESC LIMIT 1
Database: car_retails
Note: Motorcycles refer to productline = 'motorcycles'; ordered in 2004 refers to year(orderdate) = 2004;
Question: How many motorcycles have been ordered in 2004?
SQL: SELECT sum(orderdetails.quantityordered) FROM orders INNER JOIN orderdetails ON orders.ordernumber = orderdetails.ordernumber INNER JOIN products ON orderdetails.productcode = products.productcode WHERE products.productline = 'motorcycles' AND strftime('%Y', orders.orderdate) = '2004'
Database: car_retails
Note: Credit card does not have a limit refers to creditlimit = 45300;
Question: Please list the order number of the customer whose credit card has a limit of 45300.
SQL: SELECT orders.ordernumber FROM orders INNER JOIN customers ON orders.customernumber = customers.customernumber WHERE customers.creditlimit = 45300
Database: car_retails
Note: Most profitable order can be computed as MAX(MULTIPLY(quantityordered, SUBTRACT(priceeach, buyprice)).;
Question: For Which order was the most profitable, please list the customer name of the order and the profit of the order.
SQL: SELECT customers.customername, (orderdetails.priceeach - products.buyprice) * orderdetails.quantityordered FROM orderdetails INNER JOIN orders ON orderdetails.ordernumber = orders.ordernumber INNER JOIN customers ON orders.customernumber = customers.customernumber INNER JOIN products ON orderdetails.productcode = products.productcode GROUP BY customers.customername, orderdetails.priceeach, products.buyprice, orderdetails.quantityordered ORDER BY (orderdetails.priceeach - products.buyprice) * orderdetails.quantityordered DESC LIMIT 1
Database: car_retails
Note: Transactions payment lower than 10000 refer to COUNT(amount) < 1000; by year refers to YEAR(paymentdate);
Question: How many transactions payment made by customer that is lower than 10000. Group the result by year.
SQL: SELECT strftime('%Y', payments.paymentdate), count(payments.customernumber) FROM payments WHERE payments.amount < 10000 GROUP BY strftime('%Y', payments.paymentdate)
Database: car_retails
Note: Best selling products refer to products with MAX(quantityordered); 2003 refers to year(orderdate) = 2003;
Question: List out 3 best seller products during year 2003 with their total quantity sold during 2003.
SQL: SELECT products.productname, sum(orderdetails.quantityordered) FROM orders INNER JOIN orderdetails ON orders.ordernumber = orderdetails.ordernumber INNER JOIN products ON orderdetails.productcode = products.productcode WHERE strftime('%Y', orders.orderdate) = '2003' GROUP BY products.productname ORDER BY sum(orderdetails.quantityordered) DESC LIMIT 3
Database: car_retails
Note: 1969 Harley Davidson Ultimate Chopper refers to the name of the product; sale rep refers to employee; 2003 refers to year(orderdate) = 2003; quantity sold refers to quantityordered; their names refer to the name of customers;
Question: List out sale rep that has sold 1969 Harley Davidson Ultimate Chopper. List out their names and quantity sold throughout the year.
SQL: SELECT employees.firstname, employees.lastname, sum(orderdetails.quantityordered) FROM products INNER JOIN orderdetails ON products.productcode = orderdetails.productcode INNER JOIN orders ON orderdetails.ordernumber = orders.ordernumber INNER JOIN customers ON orders.customernumber = customers.customernumber INNER JOIN employees ON customers.salesrepemployeenumber = employees.employeenumber WHERE products.productname = '1969 Harley Davidson Ultimate Chopper' GROUP BY employees.lastname, employees.firstname
Database: car_retails
Note: New York city refers to city = 'NYC'; sales representative refers to jobtitle = 'Sales Rep';
Question: Who are the sales representatives in New York City? List their full names.
SQL: SELECT employees.lastname, employees.firstname FROM employees INNER JOIN offices ON employees.officecode = offices.officecode WHERE offices.city = 'NYC' AND employees.jobtitle = 'Sales Rep'
Database: car_retails
Question: Identify the customer and list down the country with the check number GG31455.
SQL: SELECT customers.customername, customers.country FROM payments INNER JOIN customers ON payments.customernumber = customers.customernumber WHERE payments.checknumber = 'GG31455'
Database: car_retails
Note: 2001 Ferrari Enzo refers to productname;
Question: How many 2001 Ferrari Enzo were ordered?
SQL: SELECT sum(orderdetails.ordernumber) FROM orderdetails INNER JOIN products ON orderdetails.productcode = products.productcode WHERE products.productname = '2001 Ferrari Enzo'
Database: car_retails
Note: The lowest amount of orders refers to MIN(quantityordered);
Question: Which 5 products has the lowest amount of orders? List the product names.
SQL: SELECT products.productname FROM orderdetails INNER JOIN products ON orderdetails.productcode = products.productcode GROUP BY products.productname ORDER BY sum(orderdetails.quantityordered) ASC LIMIT 5
Database: car_retails
Question: List down the customer names with a disputed order status.
SQL: SELECT customers.customername FROM customers INNER JOIN orders ON customers.customernumber = orders.customernumber WHERE orders.status = 'Disputed'
Database: car_retails
Note: country = 'USA';
Question: How many countries from the USA have an In Process order status?
SQL: SELECT count(orders.ordernumber) FROM customers INNER JOIN orders ON customers.customernumber = orders.customernumber WHERE orders.status = 'On Hold' AND customers.country = 'USA'
Database: car_retails
Note: SUM(MULTIPLY(quantityordered, priceeach)) where productline = 'Classic Cars'; status = 'Shipped'; customername = 'Land of Toys Inc';
Question: Calculate the total price of shipped orders belonging to Land of Toys Inc. under the classic car line of products.
SQL: SELECT sum(orderdetails.priceeach * orderdetails.quantityordered) FROM customers INNER JOIN orders ON customers.customernumber = orders.customernumber INNER JOIN orderdetails ON orders.ordernumber = orderdetails.ordernumber INNER JOIN products ON orderdetails.productcode = products.productcode WHERE products.productline = 'Classic Cars' AND customers.customername = 'Land of Toys Inc.' AND orders.status = 'Shipped'
Database: restaurant
Note: have not obtained a minimum of 3 in review refers to review < 3;
Question: How many restaurants have not obtained a minimum of 3 in their reviews?
SQL: SELECT count(id_restaurant) FROM generalinfo WHERE review < 3
Database: restaurant
Note: top-reviewed refers to review = 4; type of food refers to food_type;
Question: What types of food are served at the 4 top-reviewed restaurants?
SQL: SELECT food_type FROM generalinfo WHERE review = ( SELECT max(review) FROM generalinfo ) LIMIT 4
Database: restaurant
Note: Mediterranean food refers to food_type =   'mediterranean';
Question: How many restaurants in the city of Richmond serve Mediterranean food?
SQL: SELECT count(id_restaurant) FROM generalinfo WHERE food_type = 'mediterranean' AND city = 'richmond'
Database: restaurant
Question: List all the cities in Sonoma County.
SQL: SELECT city FROM geographic WHERE county = 'sonoma county'
Database: restaurant
Note: not in the Bay Area region refers to region ! = 'bay area';
Question: What counties are not in the Bay Area Region?
SQL: SELECT DISTINCT county FROM geographic WHERE region != 'bay area'
Database: restaurant
Question: List all cities in the Northern California Region.
SQL: SELECT city FROM geographic WHERE region = 'northern california'
Database: restaurant
Note: 11th Street refers to street_name = '11th street'; Oakland refers to city = 'oakland'; ID number of restaurant refers to id_restaurant;
Question: List by its ID number all restaurants on 11th Street in Oakland.
SQL: SELECT id_restaurant FROM LOCATION WHERE city = 'oakland' AND street_name = '11th street'
Database: restaurant
Note: number 871 on its street refers to street_num = 871;
Question: How many restaurants can we find at number 871 on its street?
SQL: SELECT count(id_restaurant) FROM LOCATION WHERE street_num = 871
Database: restaurant
Note: 9th Avenue refers to street_name = '9th avenue'; San Francisco refers to city = 'san francisco';
Question: At what numbers on 9th Avenue of San Francisco there are restaurants?
SQL: SELECT id_restaurant FROM LOCATION WHERE city = 'san francisco' AND street_name = '9th avenue'
Database: restaurant
Note: Adeline Street refers to street_name = 'adeline st'; type of food refers to food_type;
Question: What type of food is there in the restaurants on Adeline Street in Berkeley city?
SQL: SELECT generalinfo.food_type FROM generalinfo INNER JOIN LOCATION ON generalinfo.id_restaurant = LOCATION.id_restaurant WHERE LOCATION.street_name = 'adeline st' AND LOCATION.city = 'berkeley'
Database: restaurant
Note: no African food restaurants refers to food_type <> 'african';
Question: In which regions are there no African food restaurants?
SQL: SELECT DISTINCT geographic.region FROM generalinfo INNER JOIN geographic ON generalinfo.city = geographic.city WHERE generalinfo.food_type != 'african'
Database: restaurant
Note: A&W Root Beer Restaurant refers to label = 'a & w root beer';
Question: In which counties are there A&W Root Beer Restaurants?
SQL: SELECT DISTINCT geographic.county FROM generalinfo INNER JOIN geographic ON generalinfo.city = geographic.city WHERE generalinfo.label = 'a & w root beer'
Database: restaurant
Note: street refers to street_name; number refers to street_num; Adelitas Taqueria Restaurant refers to label = 'adelitas taqueria';
Question: Indicate street and number of the Adelitas Taqueria Restaurants.
SQL: SELECT LOCATION.street_name, LOCATION.street_num FROM LOCATION INNER JOIN generalinfo ON LOCATION.id_restaurant = generalinfo.id_restaurant WHERE generalinfo.label = 'adelitas taqueria'
Database: restaurant
Note: 3140 Alpine Road at San Mateo county refers to street_num = 3140 AND street_name = 'alpine rd' AND county = 'san mateo county'; type of food refers to food_type;
Question: What type of food is served at the restaurant located at 3140, Alpine Road at San Mateo County?
SQL: SELECT generalinfo.food_type FROM LOCATION INNER JOIN generalinfo ON LOCATION.id_restaurant = generalinfo.id_restaurant INNER JOIN geographic ON generalinfo.city = geographic.city WHERE geographic.county = 'san mateo county' AND LOCATION.street_name = 'alpine rd' AND LOCATION.street_num = 3140
Database: restaurant
Note: street refers to street_name; seafood refers to food_type = 'seafood';
Question: In which streets of the city of San Francisco are there restaurants that serve seafood?
SQL: SELECT LOCATION.street_name FROM LOCATION INNER JOIN generalinfo ON LOCATION.id_restaurant = generalinfo.id_restaurant WHERE LOCATION.city = 'san francisco' AND generalinfo.food_type = 'seafood' AND street_name IS NOT NULL
Database: restaurant
Note: no Bakers Square Restaurant & Pie Shop refers to label <> 'bakers square restaurant & pie shop';
Question: List all counties where there is no Bakers Square Restaurant & Pie Shop.
SQL: SELECT DISTINCT geographic.county FROM generalinfo INNER JOIN geographic ON generalinfo.city = geographic.city WHERE generalinfo.label != 'bakers square restaurant & pie shop'
Database: restaurant
Note: a street called Appian Way refers to street_name = 'appian way';
Question: In how many counties is there a street called Appian Way?
SQL: SELECT count(DISTINCT geographic.county) FROM LOCATION INNER JOIN geographic ON LOCATION.city = geographic.city WHERE LOCATION.street_name = 'appian way'
Database: restaurant
Note: Atlantic Ave refers to street_name = 'atlantic ave'; rating refers to review;
Question: What is the rating of each restaurant reviews on Atlantic Ave?
SQL: SELECT generalinfo.review FROM generalinfo INNER JOIN LOCATION ON generalinfo.id_restaurant = LOCATION.id_restaurant WHERE LOCATION.street_name = 'atlantic ave'
Database: restaurant
Question: Identify all restaurants in Contra Costa County by id.
SQL: SELECT LOCATION.id_restaurant FROM LOCATION INNER JOIN geographic ON LOCATION.city = geographic.city WHERE geographic.county = 'contra costa county'
Database: restaurant
Question: Identify all the restaurants in Yolo County by their label.
SQL: SELECT generalinfo.id_restaurant, generalinfo.label FROM generalinfo INNER JOIN geographic ON generalinfo.city = geographic.city WHERE geographic.county = 'yolo county'