Chinastark/bird_dataset huggingface dataset:
Database: works_cycles
Note: Minipump is name of a product;
Question: How many Minipumps have been sold?
SQL: SELECT count(orderqty) FROM salesorderdetail WHERE productid IN ( SELECT productid FROM product WHERE name = 'Minipump' )
Database: works_cycles
Note: business id refers to businessentityid;
Question: What is the person's business ID with a vista credit card number "11113366963373"?
SQL: SELECT personcreditcard.businessentityid FROM creditcard INNER JOIN personcreditcard ON creditcard.creditcardid = personcreditcard.creditcardid WHERE creditcard.cardnumber = 11113366963373
Database: works_cycles
Note: where the person live refers addresstype.name = 'Home';
Question: Where does the person with the BusinessEntityID "5555" live?
SQL: SELECT address.city, address.addressline1 FROM businessentityaddress INNER JOIN addresstype ON businessentityaddress.addresstypeid = addresstype.addresstypeid INNER JOIN address ON businessentityaddress.addressid = address.addressid WHERE businessentityaddress.businessentityid = 5555 AND addresstype.name = 'Home'
Database: works_cycles
Question: List all the names of products with the special offer "15".
SQL: SELECT product.name FROM specialofferproduct INNER JOIN product ON specialofferproduct.productid = product.productid WHERE specialofferproduct.specialofferid = 15
Database: works_cycles
Note: credit card number refers to creditcardid;
Question: What is the credit card number for Michelle E Cox?
SQL: SELECT creditcard.creditcardid FROM person INNER JOIN personcreditcard ON person.businessentityid = personcreditcard.businessentityid INNER JOIN creditcard ON personcreditcard.creditcardid = creditcard.creditcardid WHERE person.firstname = 'Michelle' AND person.middlename = 'E' AND person.lastname = 'Cox'
Database: works_cycles
Note: reason means the category of sales reason which refers to reasontype;
Question: What is the reason for sales order "51883"?
SQL: SELECT salesreason.name FROM salesorderheadersalesreason INNER JOIN salesreason ON salesorderheadersalesreason.salesreasonid = salesreason.salesreasonid WHERE salesorderheadersalesreason.salesorderid = 51883
Database: works_cycles
Question: What is the credit card number for the sales order "45793"?
SQL: SELECT creditcard.cardnumber FROM salesorderheader INNER JOIN creditcard ON salesorderheader.creditcardid = creditcard.creditcardid WHERE salesorderheader.salesorderid = 45793
Database: works_cycles
Note: Northwest is name of salesterritory; US is the countryregioncode;
Question: List all the sales people in the Northwest US.
SQL: SELECT salesperson.businessentityid FROM salesterritory INNER JOIN salesperson ON salesterritory.territoryid = salesperson.territoryid WHERE salesterritory.name = 'Northwest' AND salesterritory.countryregioncode = 'US'
Database: works_cycles
Note: highest pay rate refers to MAX(rate);
Question: Which Production Technician has the highest pay rate?
SQL: SELECT employee.businessentityid FROM employee INNER JOIN employeepayhistory ON employee.businessentityid = employeepayhistory.businessentityid WHERE employee.jobtitle LIKE 'Production Technician%' ORDER BY employeepayhistory.rate DESC LIMIT 1
Database: works_cycles
Note: full name = firstname+middlename+lastname;
Question: Who is the sales person in charge of the territory with the id "9"? Provide their full name.
SQL: SELECT person.firstname, person.middlename, person.lastname FROM salesperson INNER JOIN person ON salesperson.businessentityid = person.businessentityid WHERE salesperson.territoryid = 9
Database: works_cycles
Question: What is the description of the discount for the product with the id "762"?
SQL: SELECT specialoffer.description FROM specialofferproduct INNER JOIN specialoffer ON specialofferproduct.specialofferid = specialoffer.specialofferid WHERE specialofferproduct.productid = 762
Database: works_cycles
Note: male refers to gender = 'M'; female refers to gender = 'F'; difference in average rate = DIVIDE(AVG(rate where gender = 'F')), (AVG(rate where gender = 'M'))) as diff;
Question: Compare the average pay rate of male and female employees.
SQL: SELECT avg(employeepayhistory.rate) FROM employee INNER JOIN employeepayhistory ON employee.businessentityid = employeepayhistory.businessentityid GROUP BY employee.gender
Database: works_cycles
Note: percentage = DIVIDE(SUM(name = 'Night')), (COUNT(shiftid)) as percentage;
Question: What is the percentage of employees who work the night shift?
SQL: SELECT cast(sum(CASE WHEN shift.name = 'Night' THEN 1 ELSE 0 END) AS REAL) * 100 / count(employeedepartmenthistory.businessentityid) FROM shift INNER JOIN employeedepartmenthistory ON shift.shiftid = employeedepartmenthistory.shiftid
Database: works_cycles
Note: married refers to maritalstatus = 'M'; male refers to gender = 'M'; birthdate <= '1959-12-31';
Question: How many married male employees were born before the year 1960?
SQL: SELECT count(businessentityid) FROM employee WHERE maritalstatus = 'M' AND strftime('%Y', birthdate) < '1960' AND gender = 'M'
Database: works_cycles
Note: highest selling price refers to MAX(listprice);
Question: What are the top 5 types of products with the highest selling price? ?
SQL: SELECT name FROM product ORDER BY listprice DESC LIMIT 5
Database: works_cycles
Note: Accountant is a job title; first hired = MIN(hiredate);
Question: When did the company hired its first Accountant?
SQL: SELECT min(hiredate) FROM employee WHERE jobtitle = 'Accountant'
Database: works_cycles
Note: Job position and job title are synonyms; job position that was hired the most refers to MAX(COUNT(jobtitle); hiredate BETWEEN '2007-1-1' AND '2007-12-31';
Question: In 2007, which job position was hired the most?
SQL: SELECT jobtitle FROM employee WHERE strftime('%Y', hiredate) = '2007' GROUP BY hiredate ORDER BY count(jobtitle) DESC LIMIT 1
Database: works_cycles
Note: profit on net = SUBTRACT(lastreceiptcost, standardprice);
Question: What is the profit on net of the vendor with the highest standard price? If there are two vendors of the same amount, calculate only for one vendor.
SQL: SELECT lastreceiptcost - standardprice FROM productvendor ORDER BY standardprice DESC LIMIT 1
Database: works_cycles
Note: number of departments an employee works for between 2011 and 2012 refers to year(startdate) BETWEEN 2011 AND 2012 and year(enddate) BETWEEN 2011 and 2012;
Question: How many departments did Sheela Ward work in between 1/1/2011 to 12/31/2012
SQL: SELECT count(department.name) FROM person INNER JOIN employeedepartmenthistory ON person.businessentityid = employeedepartmenthistory.businessentityid INNER JOIN department ON employeedepartmenthistory.departmentid = department.departmentid WHERE person.firstname = 'Sheela' AND person.lastname = 'Word' AND strftime('%Y', department.modifieddate) BETWEEN '2011' AND '2012'
Database: works_cycles
Note: average age as of 12/31/2009 = AVG(SUBTRACT(2009, year(birthdate));
Question: What is the average age of the sales agents in the company by 12/31/2009?
SQL: SELECT avg(2009 - strftime('%Y', employee.birthdate)) FROM person INNER JOIN employee ON person.businessentityid = employee.businessentityid WHERE person.persontype = 'SP'
Database: works_cycles
Note: least amount of workers refers to MIN(count(departmentid));
Question: To which group does the department with the least amount of workers belong to? Indicate the name of the department as well.
SQL: SELECT department.groupname FROM employeedepartmenthistory INNER JOIN department ON employeedepartmenthistory.departmentid = department.departmentid GROUP BY department.groupname ORDER BY count(employeedepartmenthistory.businessentityid) LIMIT 1
Database: works_cycles
Note: age as of 12/31/2015 = SUBTRACT(2015, year(birthdate)); hourly rate refers to rate;
Question: What is the age of the oldest Marketing Specialist by 12/31/2015 and what is his/her hourly rate?
SQL: SELECT 2015 - strftime('%Y', employee.birthdate), employeepayhistory.rate FROM employee INNER JOIN employeepayhistory ON employee.businessentityid = employeepayhistory.businessentityid WHERE employee.jobtitle = 'Marketing Specialist' ORDER BY 2015 - strftime('%Y', employee.birthdate) DESC LIMIT 1
Database: works_cycles
Note: vendor's selling price of a single product refers to unitprice;
Question: What is the total amount due of all the purchases made by the company to the vendor that has the lowest selling price amount of a single product? Indicate the name of the vendor to which the purchases was made.
SQL: SELECT purchaseorderdetail.unitprice, vendor.name FROM purchaseorderdetail INNER JOIN purchaseorderheader ON purchaseorderdetail.purchaseorderid = purchaseorderheader.purchaseorderid INNER JOIN vendor ON purchaseorderheader.vendorid = vendor.businessentityid ORDER BY purchaseorderdetail.unitprice LIMIT 1
Database: works_cycles
Note: total due before freight = SUBTRACT(totaldue, freight); age at the time an employee was hired = SUBTRACT(hiredate, year(birthdate);
Question: Who made the purchase order with the greatest total due before freight? Indicate her employee ID and calculate for his/her age when he/she was hired.
SQL: SELECT employee.businessentityid, strftime('%Y', employee.hiredate) - strftime('%Y', employee.birthdate) FROM purchaseorderheader INNER JOIN employee ON purchaseorderheader.employeeid = employee.businessentityid ORDER BY purchaseorderheader.totaldue DESC LIMIT 1
Database: works_cycles
Note: salary and rate are synonyms; full name = firstname+middlename+lastname;
Question: What is the position of the employee with the 10th highest salary? Indicate his/her salary amount and his/her full name.
SQL: SELECT employee.jobtitle, employeepayhistory.rate, person.firstname, person.middlename, person.lastname FROM employeepayhistory INNER JOIN employee ON employeepayhistory.businessentityid = employee.businessentityid INNER JOIN person ON employee.businessentityid = person.businessentityid ORDER BY employeepayhistory.rate DESC LIMIT 9, 1
Database: works_cycles
Note: highest rating refers to rating = 5; profit = SUBTRACT(listprice, standardcost);
Question: What is the profit of a single product that received the highest rating from John Smith? List the product/s' names.
SQL: SELECT product.listprice - product.standardcost, product.name FROM product INNER JOIN productreview ON product.productid = productreview.productid WHERE productreview.reviewername = 'John Smith' ORDER BY productreview.rating DESC LIMIT 1
Database: works_cycles
Note: salary rate per hour refers to rate; first 5 employees that were hired refers to 5 oldest hiredate;
Question: What is the salary rate per hour that the company paid to the first 5 employees that they hired?
SQL: SELECT employeepayhistory.rate FROM employeepayhistory INNER JOIN employee ON employeepayhistory.businessentityid = employee.businessentityid INNER JOIN person ON employee.businessentityid = person.businessentityid ORDER BY employee.hiredate ASC LIMIT 0, 5
Database: works_cycles
Note: maximum orders refers to maxorderqty; maxorderqty BETWEEN '500' AND '750'; profit on net = SUBTRACT(lastreceiptcost, standardprice);
Question: Among the vendors with maximum orders betweeen 500 to 750, which vendor has the 10th highest profit on net?
SQL: SELECT vendor.name FROM productvendor INNER JOIN vendor ON productvendor.businessentityid = vendor.businessentityid WHERE productvendor.maxorderqty BETWEEN 500 AND 750 ORDER BY productvendor.lastreceiptcost - productvendor.standardprice DESC LIMIT 9, 1
Database: works_cycles
Note: pending for approval papers refer to status = 1; length of stay in the company as of 12/31/2011 = SUBTRACT(2011, year(hiredate));
Question: As of 12/31/2011, how long has the employee assigned to all pending for approval papers been working in the company from the date he was hired?
SQL: SELECT 2011 - strftime('%Y', employee.hiredate) FROM document INNER JOIN employee ON document.owner = employee.businessentityid WHERE document.status = 1
Database: works_cycles
Note: second-lowest rating refers to rating = 2; high-quality class product refers to class = 'H'; length of time it takes the company to manufacture a product refers to daystomanufacture;
Question: Jill ranked which medium-quality class product as the highest, and how long will it take the company to manufacture such a product?
SQL: SELECT product.daystomanufacture FROM product INNER JOIN productreview ON product.productid = productreview.productid WHERE productreview.rating = 5 AND product.class = 'M' ORDER BY productreview.rating LIMIT 1
Database: works_cycles
Note: job position and job title are synonyms; full name = firstname+middlename+lastname;
Question: What was the first job position that the company needed, and who was hired? Indicate his/her full name.
SQL: SELECT employee.jobtitle, person.firstname, person.middlename, person.lastname FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid ORDER BY employee.hiredate LIMIT 1
Database: works_cycles
Note: work order refers to transactiontype = 'W'; quantity BETWEEN 100 AND 250; reorderpoint<= 375;
Question: How many work orders with quantities ranging from 100 to 250 have a reorder point of no more than 375?
SQL: SELECT count(transactionhistory.transactionid) FROM transactionhistory INNER JOIN product ON transactionhistory.productid = product.productid WHERE transactionhistory.quantity BETWEEN 100 AND 250 AND product.reorderpoint <= 375
Database: works_cycles
Note: female refers to gender = 'F'; male refers to gender = 'M'; difference in the average salary of female against male employees = SUBTRACT(AVG(rate where gender = 'F')), (AVG(rate where gender = 'M')));
Question: How much is the average salary of female employees in comparison to male employees?
SQL: SELECT avg(employeepayhistory.rate) FROM employee INNER JOIN employeepayhistory ON employee.businessentityid = employeepayhistory.businessentityid WHERE employee.gender = 'F'
Database: works_cycles
Note: product is purchased refers to makeflag = 0; women's refers to style = 'W'; productsubcategoryid = 'Tights';
Question: What are the names of the vendors to which the company purchased its women's tights products?
SQL: SELECT DISTINCT vendor.name FROM product INNER JOIN productvendor ON product.productid = productvendor.productid INNER JOIN productsubcategory ON product.productsubcategoryid = productsubcategory.productsubcategoryid INNER JOIN vendor ON productvendor.businessentityid = vendor.businessentityid WHERE product.makeflag = 0 AND product.style = 'W' AND productsubcategory.name = 'Tights'
Database: works_cycles
Note: payfrequency = 1 refers to ‘Salary received monthly’; payfrequency = 2 refers to ‘Salary received biweekly';
Question: How frequently does the first-ever Scheduling Assistant get paid?
SQL: SELECT employeepayhistory.payfrequency FROM employee INNER JOIN employeepayhistory ON employee.businessentityid = employeepayhistory.businessentityid WHERE employee.jobtitle = 'Scheduling Assistant' ORDER BY employee.hiredate LIMIT 1
Database: works_cycles
Note: fewest online orders refer to MIN(quantity);
Question: What product has the fewest online orders from one customer? List the product's class, line of business, and list price.
SQL: SELECT product.class, product.productline, product.listprice FROM shoppingcartitem INNER JOIN product ON shoppingcartitem.productid = product.productid GROUP BY shoppingcartitem.productid ORDER BY sum(quantity) LIMIT 1
Database: works_cycles
Note: commision percent received per sale refers to commissionpct; highest commision percent received per sale refers to MAX(commissionpct); full name = firstname+middlename+lastname;
Question: What is the full name of the sales person who has the the highest commission percent received per sale?
SQL: SELECT person.firstname, person.middlename, person.lastname FROM salesperson INNER JOIN person ON salesperson.businessentityid = person.businessentityid ORDER BY salesperson.commissionpct DESC LIMIT 1
Database: works_cycles
Note: age at the time of being hired = SUBTRACT(hiredate, birthdate); full name = firstname+middlename+lastname;
Question: What is the full name of the second oldest person in the company at the time he was hired?
SQL: SELECT person.firstname, person.middlename, person.lastname FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid ORDER BY strftime('%Y', employee.hiredate) - strftime('%Y', employee.birthdate) DESC LIMIT 1, 1
Database: works_cycles
Note: profit = MULTIPLY(SUBTRACT(listprice, standardcost)), (quantity)));
Question: What is the total profit gained by the company from the product that has the highest amount of quantity ordered from online customers? Indicate the name of the product.
SQL: SELECT (product.listprice - product.standardcost) * sum(shoppingcartitem.quantity), product.name FROM shoppingcartitem INNER JOIN product ON shoppingcartitem.productid = product.productid GROUP BY shoppingcartitem.productid, product.name, product.listprice, product.standardcost, shoppingcartitem.quantity ORDER BY sum(shoppingcartitem.quantity) DESC LIMIT 1
Database: works_cycles
Note: highest amount of difference between the ordered quantity and actual quantity received in a single purchase order refers to MAX(SUBTRACT(orderqty, receivedqty));
Question: What is the highest amount of difference between the ordered quantity and actual quantity received in a single purchase order and to which vendor was the purchase order made?
SQL: SELECT purchaseorderdetail.orderqty - purchaseorderdetail.receivedqty, vendorid FROM purchaseorderheader INNER JOIN purchaseorderdetail ON purchaseorderheader.purchaseorderid = purchaseorderdetail.purchaseorderid ORDER BY purchaseorderdetail.orderqty - purchaseorderdetail.receivedqty DESC LIMIT 1
Database: works_cycles
Note: Profit on net = SUBTRACT(lastreceiptcost, standardprice); full location = addressline1+addressline2+city+postalcode;
Question: What is the average lead time of product ID 843? Calculate for its profit on net and indicate the full location to which the vendor is located.
SQL: SELECT productvendor.averageleadtime, productvendor.lastreceiptcost - productvendor.standardprice, address.addressline1, address.addressline2 , address.city, address.postalcode FROM productvendor INNER JOIN vendor ON productvendor.businessentityid = vendor.businessentityid INNER JOIN businessentityaddress ON productvendor.businessentityid = businessentityaddress.businessentityid INNER JOIN address ON businessentityaddress.addressid = address.addressid WHERE productvendor.productid = 843
Database: works_cycles
Note: salesperson that haven't met the quota refers to bonus = 0;
Question: How many salespersons haven't met quota?
SQL: SELECT count(businessentityid) FROM salesperson WHERE bonus = 0
Database: works_cycles
Note: tax applied to retail transaction refers to taxtype = 1; sales that are charged with multiple types of tax refers to name LIKE '%+%';
Question: Among the sales with a tax applied to retail transaction, how many of them are charged by multiple types of taxes?
SQL: SELECT count(salestaxrateid) FROM salestaxrate WHERE name LIKE '%+%'
Database: works_cycles
Note: product cost refers to actualcost; purchase order refers to transactiontype = 'P';
Question: Please give the highest product cost of a purchase order.
SQL: SELECT actualcost FROM transactionhistory WHERE transactiontype = 'P' ORDER BY actualcost DESC LIMIT 1
Database: works_cycles
Note: shipping cost and freight are synonyms; highest shipping cost refers to MAX(freight);
Question: What is the current status of the order with the highest shipping cost?
SQL: SELECT status FROM salesorderheader ORDER BY freight DESC LIMIT 1
Database: works_cycles
Note: out of stock product refers to onorderqty = 0;
Question: How many products are out of stock?
SQL: SELECT count(productid) FROM productvendor WHERE onorderqty = 0
Database: works_cycles
Note: profit on net = subtract(lastreceiptcost, standardprice);
Question: What is the highest profit on net for a product?
SQL: SELECT lastreceiptcost - standardprice FROM productvendor ORDER BY lastreceiptcost - standardprice DESC LIMIT 1
Database: works_cycles
Note: highest rating refers to MAX(rating);
Question: Which reviewer gives the biggest number of the highest rating?
SQL: SELECT reviewername FROM productreview WHERE rating = ( SELECT rating FROM productreview ORDER BY rating DESC LIMIT 1 )
Database: works_cycles
Note: most reviews refers to MAX(count(productid));
Question: Which product gets the most reviews?
SQL: SELECT product.name FROM productreview INNER JOIN product ON productreview.productid = product.productid GROUP BY productreview.productid ORDER BY count(productreview.productreviewid) DESC LIMIT 1
Database: works_cycles
Note: product that are purchased refers to makeflag = 0; never received highest rating refers to rating! = 5;
Question: Among the products that are purchased, how many of them have never received the highest rating?
SQL: SELECT count(productreview.productid) FROM productreview INNER JOIN product ON productreview.productid = product.productid WHERE product.makeflag = 0 AND productreview.rating != 5
Database: works_cycles
Note: salable product refers to finishedgoodsflag = 1; biggest amount reviews refers to MAX(count(productid));
Question: What is the biggest amount of reviews a salable product gets?
SQL: SELECT productreview.comments FROM productreview INNER JOIN product ON productreview.productid = product.productid WHERE product.finishedgoodsflag = 1 GROUP BY productreview.comments ORDER BY count(productreview.productreviewid) DESC LIMIT 1
Database: works_cycles
Note: manufactured in house refers to makeflag = 1; salable product refers to finishedgoodsflag = 1; over 10 reviews refers to count(comments)>10;
Question: Among the products that are both manufactured in house and salable, how many of them get over 10 reviews?
SQL: SELECT product.name FROM productreview INNER JOIN product USING (productid) WHERE product.finishedgoodsflag = 1 AND product.makeflag = 1 GROUP BY product.name ORDER BY count(productreview.comments) > 10
Database: works_cycles
Note: salable product refers to finishedgoodsflag = 1; over 10 reviews refers to count(comments)>10;
Question: Please list the names of the products that get over 10 reviews and a salable.
SQL: SELECT product.name FROM productreview INNER JOIN product ON productreview.productid = product.productid WHERE product.finishedgoodsflag = 1 GROUP BY product.name ORDER BY count(productreview.comments) > 10
Database: works_cycles
Note: highest rating refers to rating = 5; high class refers to class = 'H'; men's product refers to style = 'M';
Question: Please list the reviewers who have given the highest rating for a medium class, women's product.
SQL: SELECT productreview.reviewername FROM productreview INNER JOIN product ON productreview.productid = product.productid WHERE product.class = 'M' AND product.style = 'W' AND productreview.rating = 5
Database: works_cycles
Note: most review refers to MAX(count(comments)); high class refers to class = 'H'; medium class refers to class = 'M'; low class refers to class = 'L';
Question: What is the class of the product with the most reviews?
SQL: SELECT product.class FROM productreview INNER JOIN product ON productreview.productid = product.productid GROUP BY product.class ORDER BY count(productreview.productreviewid) DESC LIMIT 1
Database: works_cycles
Note: high class refers to class = 'H'; men's product refers to style = 'M';
Question: Please list the e-mails of the reviewers who have reviewed high class.
SQL: SELECT productreview.emailaddress FROM productreview INNER JOIN product ON productreview.productid = product.productid WHERE product.class = 'H'
Database: works_cycles
Note: over 3 price changes refers to count(listprice)>3;
Question: Please list the names of the products that have over 3 price changes.
SQL: SELECT product.name FROM productlistpricehistory INNER JOIN product ON productlistpricehistory.productid = product.productid GROUP BY product.name ORDER BY count(productlistpricehistory.listprice) > 3
Database: works_cycles
Note: Headset Ball Bearings is name of a product;
Question: What is the product description of Headset Ball Bearings?
SQL: SELECT productdescription.description FROM productdescription INNER JOIN product WHERE product.name = 'Headset Ball Bearings' AND productdescription.productdescriptionid = product.productid