Chinastark/bird_dataset huggingface dataset:
Database: works_cycles
Note: employees who wish to receive e-mail promotions from AdventureWorks and selected partners refers to emailpromotion = 2;
Question: Please list the e-mail addresses of all the employees who wish to receive e-mail promotions from Adventureworks and selected partners.
SQL: SELECT emailaddress.emailaddress FROM person INNER JOIN emailaddress ON person.businessentityid = emailaddress.businessentityid WHERE person.emailpromotion = 2
Database: works_cycles
Note: credit card number refers to cardnumber;
Question: Please show the credit card number of David Bradley.
SQL: SELECT creditcard.cardnumber FROM person INNER JOIN personcreditcard ON person.businessentityid = personcreditcard.businessentityid INNER JOIN creditcard ON personcreditcard.creditcardid = creditcard.creditcardid WHERE person.firstname = 'David' AND person.lastname = 'Bradley'
Database: works_cycles
Note: year of credit card expiration refers to expyear;
Question: In which year will the David Bradley's credit card expire?
SQL: SELECT creditcard.expyear FROM person INNER JOIN personcreditcard ON person.businessentityid = personcreditcard.businessentityid INNER JOIN creditcard ON personcreditcard.creditcardid = creditcard.creditcardid WHERE person.firstname = 'David' AND person.lastname = 'Bradley'
Database: works_cycles
Note: year of credit card expiration refers to expyear; expyear = 2007; store contact refers to persontype = 'SC';
Question: Please list the names of all the store contact employees whose credit cards expired in 2007.
SQL: SELECT person.firstname, person.lastname FROM person INNER JOIN personcreditcard ON person.businessentityid = personcreditcard.businessentityid INNER JOIN creditcard ON personcreditcard.creditcardid = creditcard.creditcardid WHERE creditcard.expyear = 2007 AND person.persontype = 'SC'
Database: works_cycles
Note: store contact refers to persontype = 'SC'; type of credit card refers to cardtype; cardtype = 'vista';
Question: Among the store contact employees, how many of them have a Vista credit card?
SQL: SELECT count(person.firstname) FROM person INNER JOIN personcreditcard ON person.businessentityid = personcreditcard.businessentityid INNER JOIN creditcard ON personcreditcard.creditcardid = creditcard.creditcardid WHERE creditcard.cardtype = 'Vista' AND person.persontype = 'SC'
Database: works_cycles
Question: How many departments have David Bradley been in?
SQL: SELECT count(department.departmentid) FROM person INNER JOIN employeedepartmenthistory ON person.businessentityid = employeedepartmenthistory.businessentityid INNER JOIN department ON employeedepartmenthistory.departmentid = department.departmentid WHERE person.firstname = 'David' AND person.lastname = 'Bradley'
Database: works_cycles
Question: Please list the departments that David Bradley used to belong to.
SQL: SELECT employeedepartmenthistory.departmentid FROM person INNER JOIN employeedepartmenthistory ON person.businessentityid = employeedepartmenthistory.businessentityid INNER JOIN department ON employeedepartmenthistory.departmentid = department.departmentid WHERE person.firstname = 'David' AND person.lastname = 'Bradley'
Database: works_cycles
Note: year(enddate)>2009 and year(startdate)<2009;
Question: How many people were there in the Engineering Department in the year 2009?
SQL: SELECT count(person.businessentityid) FROM person INNER JOIN employeedepartmenthistory ON person.businessentityid = employeedepartmenthistory.businessentityid INNER JOIN department ON employeedepartmenthistory.departmentid = department.departmentid WHERE department.name = 'Engineering' AND strftime('%Y', employeedepartmenthistory.enddate) > '2009' AND strftime('%Y', employeedepartmenthistory.startdate) < '2009'
Database: works_cycles
Note: length of stay in a department = SUBTRACT(enddate, startdate);
Question: Which employee has been in the Engineering Department the longest? Please give his or her firstname and lastname.
SQL: SELECT person.firstname, person.lastname FROM person INNER JOIN employeedepartmenthistory ON person.businessentityid = employeedepartmenthistory.businessentityid INNER JOIN department ON employeedepartmenthistory.departmentid = department.departmentid WHERE department.name = 'Engineering' ORDER BY employeedepartmenthistory.enddate - employeedepartmenthistory.startdate DESC LIMIT 1
Database: works_cycles
Note: store contact refers to persontype = 'SC'; year(enddate)>2007 and year(startdate)<2007;
Question: Among the employees in the Manufacturing group in 2007, how many of them are store contacts?
SQL: SELECT count(employeedepartmenthistory.businessentityid) FROM employeedepartmenthistory INNER JOIN department ON employeedepartmenthistory.departmentid = department.departmentid INNER JOIN person ON employeedepartmenthistory.businessentityid WHERE person.persontype = 'SC' AND department.groupname = 'Manufacturing' AND strftime('%Y', employeedepartmenthistory.enddate) >= '2007' AND strftime('%Y', employeedepartmenthistory.startdate) <= '2007'
Database: works_cycles
Note: credit card number refers to cardnumber; employees who left the department refers to enddate NOT null; Engineering department is a name of department;
Question: Please list the credit card numbers of all the employees who have left the Finance Department.
SQL: SELECT creditcard.cardnumber FROM employeedepartmenthistory INNER JOIN department ON employeedepartmenthistory.departmentid = department.departmentid INNER JOIN creditcard ON employeedepartmenthistory.modifieddate = creditcard.modifieddate INNER JOIN personcreditcard ON creditcard.creditcardid = personcreditcard.creditcardid WHERE department.name = 'Finance' AND employeedepartmenthistory.enddate IS NOT NULL
Database: works_cycles
Note: year(startdate) 2007; year of credit card expiration refers to expyear; expyear = 2007;
Question: How many employees working in the Engineering Department in 2007 would have their credit cards expired in the same year?
SQL: SELECT count(employeedepartmenthistory.businessentityid) FROM employeedepartmenthistory INNER JOIN department ON employeedepartmenthistory.departmentid = department.departmentid INNER JOIN personcreditcard ON employeedepartmenthistory.businessentityid = personcreditcard.businessentityid INNER JOIN creditcard ON personcreditcard.creditcardid = creditcard.creditcardid WHERE creditcard.expyear = 2007 AND department.name = 'Engineering'
Database: works_cycles
Note: switched department the most refers to MAX(count(departmentid));
Question: What is the e-mail address of the employee who switched departments for the most times?
SQL: SELECT emailaddress.emailaddress FROM employeedepartmenthistory INNER JOIN emailaddress ON employeedepartmenthistory.businessentityid = emailaddress.businessentityid GROUP BY emailaddress.businessentityid ORDER BY count(employeedepartmenthistory.departmentid) DESC LIMIT 1
Database: works_cycles
Note: employees who don't wish to receive e-mail promotions refers to emailpromotion = 0;
Question: Among all the employees who don't wish to receive promotion e-mails, how many of them belong to or once belonged to the Engineering Department?
SQL: SELECT count(employeedepartmenthistory.businessentityid) FROM employeedepartmenthistory INNER JOIN person ON employeedepartmenthistory.businessentityid = person.businessentityid INNER JOIN department ON employeedepartmenthistory.departmentid = department.departmentid WHERE department.name = 'Engineering' AND person.emailpromotion = 0
Database: works_cycles
Note: Quality Assurance group is a group name of department; came in 2007 refers to year(startdate) = 2007;
Question: How many employees came into the Quality Assurance Group in the year 2007?
SQL: SELECT count(employeedepartmenthistory.businessentityid) FROM employeedepartmenthistory INNER JOIN department ON employeedepartmenthistory.departmentid = department.departmentid WHERE department.groupname = 'Quality Assurance' AND strftime('%Y', employeedepartmenthistory.startdate) = '2007'
Database: works_cycles
Note: LL Road Frame Sale is a description of special offer;
Question: Please list the product names of all the products on the LL Road Frame Sale.
SQL: SELECT product.name FROM specialoffer INNER JOIN specialofferproduct ON specialoffer.specialofferid = specialofferproduct.specialofferid INNER JOIN product ON specialofferproduct.productid = product.productid WHERE specialoffer.description = 'LL Road Frame Sale'
Database: works_cycles
Note: LL Road Frame Sale is a description of special offer;
Question: How many products were on the LL Road Frame Sale?
SQL: SELECT count(DISTINCT productid) FROM specialoffer INNER JOIN specialofferproduct ON specialoffer.specialofferid = specialofferproduct.specialofferid WHERE specialoffer.description = 'LL Road Frame Sale'
Database: works_cycles
Note: a product that's been on sale refers to sellstartdate NOT null and vice versa;
Question: Has the product Chainring Bolts been on any of the sales?
SQL: SELECT CASE WHEN count(specialoffer.description) >= 1 THEN 'Yes' ELSE 'No' END FROM specialoffer INNER JOIN specialofferproduct ON specialoffer.specialofferid = specialofferproduct.specialofferid INNER JOIN product ON specialofferproduct.productid = product.productid WHERE product.name = 'Chainring Bolts'
Database: works_cycles
Note: LL Road Frame Sale is a description of special offer;
Question: How many products from the Clothing category were on the LL Road Frame Sale?
SQL: SELECT count(specialofferproduct.productid) FROM specialoffer INNER JOIN specialofferproduct ON specialoffer.specialofferid = specialofferproduct.specialofferid INNER JOIN product ON specialofferproduct.productid = product.productid INNER JOIN productsubcategory ON product.productsubcategoryid = productsubcategory.productsubcategoryid INNER JOIN productcategory ON productsubcategory.productcategoryid = productcategory.productcategoryid WHERE specialoffer.description = 'LL Road Frame Sale' AND productsubcategory.name = 'Clothing'
Database: works_cycles
Note: product is manufactured in-house refers to makeflag = 1; salable product refers to finishedgoodsflag = 1;
Question: Please list the products that are under the Clothing category that are manufactured in-house and salable.
SQL: SELECT CASE WHEN product.makeflag = 1 THEN product.name END FROM product INNER JOIN productsubcategory ON product.productsubcategoryid = productsubcategory.productsubcategoryid INNER JOIN productcategory ON productsubcategory.productcategoryid = productcategory.productcategoryid WHERE productsubcategory.productsubcategoryid = 3
Database: works_cycles
Note: employees who left a department refers to enddate NOT null; average stay = AVG(SUBTRACT(year(enddate)), (year(T1.startdate)));
Question: For all the employees that have left the Engineering Department, what is the average time of their stay?
SQL: SELECT cast(sum(365 * (strftime('%Y', employeedepartmenthistory.enddate) - strftime('%Y', employeedepartmenthistory.startdate)) + 30 * (strftime('%m', employeedepartmenthistory.enddate) - strftime('%m', employeedepartmenthistory.startdate)) + strftime('%d', employeedepartmenthistory.enddate) - strftime('%d', employeedepartmenthistory.startdate)) AS REAL) / count(employeedepartmenthistory.businessentityid) FROM employeedepartmenthistory INNER JOIN department ON employeedepartmenthistory.departmentid = department.departmentid WHERE department.name = 'Engineering' AND employeedepartmenthistory.enddate IS NOT NULL
Database: works_cycles
Note: average pay rate = AVG(rate); work in 2007 refers to year(startdate)<2007 AND year(enddate)>2007;
Question: What is the average pay rate of the employees who worked in the Engineering Departmentin 2007?
SQL: SELECT avg(employeepayhistory.rate) FROM employeedepartmenthistory INNER JOIN department ON employeedepartmenthistory.departmentid = department.departmentid INNER JOIN employeepayhistory ON employeedepartmenthistory.businessentityid = employeepayhistory.businessentityid WHERE department.name = 'Engineering' AND strftime('%Y', enddate) > '2007' AND strftime('%Y', employeedepartmenthistory.startdate) < '2007'
Database: works_cycles
Note: selling price refers to listprice; highest selling price refers to MAX(listprice); lowest selling price refers to MIN(listprice);
Question: How much more expensive in percentage is the product with the highest selling price from the product with the lowest selling price in the Clothing category?
SQL: SELECT (max(product.listprice) - min(product.listprice)) * 100 / min(product.listprice) FROM product INNER JOIN productsubcategory ON product.productsubcategoryid = productsubcategory.productsubcategoryid INNER JOIN productcategory ON productsubcategory.productcategoryid = productcategory.productcategoryid WHERE productcategory.name = 'Clothing'
Database: works_cycles
Note: average profit = DIVIDE(SUM(SUBTRACT(listprice, standardcost))), (COUNT(productsubcategoryid))));
Question: What is the average profit of all the products from the Clothing category?
SQL: SELECT sum(product.listprice - product.standardcost) / count(product.productid) FROM product INNER JOIN productsubcategory ON product.productsubcategoryid = productsubcategory.productsubcategoryid INNER JOIN productcategory ON productsubcategory.productcategoryid = productcategory.productcategoryid WHERE productcategory.name = 'Clothing'
Database: works_cycles
Note: cost refers to standardcost; cost the least refers to MIN(standardcost);
Question: Which product cost the least in 2013?
SQL: SELECT productid FROM productcosthistory WHERE startdate LIKE '2013%' ORDER BY standardcost LIMIT 1
Database: works_cycles
Question: List all products with the color yellow.
SQL: SELECT productid FROM product WHERE color = 'Yellow'
Database: works_cycles
Note: business id refers to businessentityid;
Question: What is the bussiness id for Mr. Hung-Fu Ting?
SQL: SELECT businessentityid FROM person WHERE title = 'Mr.' AND firstname = 'Hung-Fu' AND lastname = 'Ting'
Database: works_cycles
Note: person with id refers to businessentityid;
Question: What is the phone number of the person with id "12597"?
SQL: SELECT phonenumber FROM personphone WHERE businessentityid = 12597
Database: works_cycles
Note: price refers to listprice;
Question: What is the price for the product with the id "912"?
SQL: SELECT listprice FROM productlistpricehistory WHERE productid = 912
Database: works_cycles
Note: planned cost is different from actual cost refers to actualcost ! = plannedcost;
Question: Is there a work order where the planned cost is different from the actual cost?
SQL: SELECT CASE WHEN actualcost = plannedcost THEN 'No' ELSE 'Yes' END FROM workorderrouting
Database: works_cycles
Note: thumbnail photo file refers to thumbnailphotofilename;
Question: What is the thumbnail photo file for the product with the id "979"?
SQL: SELECT productphoto.thumbnailphotofilename FROM productproductphoto INNER JOIN productphoto ON productproductphoto.productphotoid = productphoto.productphotoid WHERE productproductphoto.productid = 979
Database: works_cycles
Note: listprice>1000;
Question: List all the names of the products with the price of more than 1000$.
SQL: SELECT DISTINCT product.name FROM productlistpricehistory INNER JOIN product ON productlistpricehistory.productid = product.productid WHERE productlistpricehistory.listprice > 1000
Database: works_cycles
Note: profit = SUBTRACT(listprice, standardcost);
Question: What is the product with the most profit?
SQL: SELECT productlistpricehistory.productid FROM productlistpricehistory INNER JOIN productcosthistory ON productlistpricehistory.productid = productcosthistory.productid ORDER BY productlistpricehistory.listprice - productcosthistory.standardcost DESC LIMIT 1
Database: works_cycles
Note: compartment refers to shelf;
Question: What is the name of the product stored in location 1 compartment L container 6?
SQL: SELECT product.name FROM productinventory INNER JOIN product ON productinventory.productid = product.productid WHERE productinventory.locationid = 1 AND productinventory.shelf = 'L' AND productinventory.bin = 6
Database: works_cycles
Question: What are locations of the work order "35493"?
SQL: SELECT LOCATION.name FROM workorderrouting INNER JOIN LOCATION ON workorderrouting.locationid = LOCATION.locationid WHERE workorderrouting.workorderid = 35493
Database: works_cycles
Note: product with large photo refers to largephoto NOT null;
Question: What are the products with a large photo?
SQL: SELECT productproductphoto.productid FROM productphoto INNER JOIN productproductphoto ON productphoto.productphotoid = productproductphoto.productphotoid WHERE productphoto.largephotofilename LIKE '%large.gif'
Database: works_cycles
Note: Socks is a name of product subcategory;
Question: List all the socks products.
SQL: SELECT product.productid FROM productsubcategory INNER JOIN product ON productsubcategory.productsubcategoryid = product.productsubcategoryid WHERE productsubcategory.name = 'Socks'
Database: works_cycles
Note: number of products a $100 can buy = DIVIDE(100, listprice);
Question: With 100$, how many Cable Lock can you buy?
SQL: SELECT 100 / productlistpricehistory.listprice FROM product INNER JOIN productlistpricehistory ON product.productid = productlistpricehistory.productid WHERE product.name = 'Cable Lock'
Database: works_cycles
Question: What is the scrap reason for work order "57788"?
SQL: SELECT scrapreason.name FROM workorder INNER JOIN scrapreason ON workorder.scrapreasonid = scrapreason.scrapreasonid WHERE workorder.workorderid = 57788
Database: works_cycles
Note: cost refers to standardcost;
Question: What is the cost for the sports?
SQL: SELECT productcosthistory.standardcost FROM product INNER JOIN productcosthistory ON product.productid = productcosthistory.productid WHERE product.name LIKE '%Sport%'
Database: works_cycles
Note: Metal Storage is name of location;
Question: How many products with the id "476" are stored in Metal Storage?
SQL: SELECT productinventory.quantity FROM LOCATION INNER JOIN productinventory ON LOCATION.locationid = productinventory.locationid WHERE productinventory.productid = 476 AND LOCATION.name = 'Metal Storage'
Database: works_cycles
Note: cost refers to standardcost; lower than average cost = standardcost<(AVG(standardcost));
Question: List all the products with lower than average cost.
SQL: SELECT DISTINCT product.productid FROM productcosthistory INNER JOIN product ON productcosthistory.productid = product.productid WHERE productcosthistory.standardcost < ( SELECT sum(standardcost) / count(productid) FROM product )
Database: works_cycles
Note: percentage of profit = DIVIDE(SUBTRACT(listprice, standardcost), (standardcost)) as percentage;
Question: What is the the percentage of profit for the product "858"?
SQL: SELECT (productlistpricehistory.listprice - productcosthistory.standardcost) * 100 / productcosthistory.standardcost FROM productlistpricehistory INNER JOIN productcosthistory ON productlistpricehistory.productid = productcosthistory.productid WHERE productlistpricehistory.productid = 858
Database: works_cycles
Note: products with a thumbnail photo refers to productphotoid ! = 1 ;
Question: How many products with a thumpnail photo?
SQL: SELECT count(productid) FROM productproductphoto WHERE productphotoid != 1
Database: works_cycles
Note: days to end a work order = SUBTRACT(actualenddate, actualstartdate);
Question: How many days did it take to end the work order "425"?
SQL: SELECT 365 * (strftime('%Y', actualenddate) - strftime('%Y', actualstartdate)) + 30 * (strftime('%m', actualenddate) - strftime('%m', actualstartdate)) + strftime('%d', actualenddate) - strftime('%d', actualstartdate) FROM workorderrouting WHERE workorderid = 425
Database: works_cycles
Note: price refers to listprice; highest price refers to MAX(listprice);
Question: Which product has the highest price in 2012?
SQL: SELECT productid FROM productlistpricehistory WHERE startdate LIKE '2012%' ORDER BY listprice DESC LIMIT 1
Database: works_cycles
Note: cost refers to standardcost;
Question: What is the cost for the product "847"?
SQL: SELECT standardcost FROM productcosthistory WHERE productid = 847
Database: works_cycles
Note: Human Resources Manager is a job title;
Question: What is the organization level for Human Resources Manager?
SQL: SELECT organizationlevel FROM employee WHERE jobtitle = 'Human Resources Manager'
Database: works_cycles
Note: workers who did not meet the due date refers to enddate>duedate;
Question: How many of the work orders didn’t meet the due date?
SQL: SELECT count(workorderid) FROM workorder WHERE enddate > duedate
Database: works_cycles
Note: cost refers to standardcost;
Question: What is the cost and the product number of product with the id "888"?
SQL: SELECT product.standardcost, product.productnumber FROM productcosthistory INNER JOIN product ON productcosthistory.productid = product.productid WHERE productcosthistory.productid = 888
Database: works_cycles
Note: products using roadster_black_small.gif as the thumbnail photo refers to thumbnailphotofilename = 'roadster_black_small.gif';
Question: How many products using "roadster_black_small.gif" as the thumbnail photo?
SQL: SELECT count(DISTINCT productproductphoto.productid) FROM productphoto INNER JOIN productproductphoto ON productphoto.productphotoid = productproductphoto.productphotoid WHERE productphoto.largephotofilename = 'roadster_black_large.gif'
Database: works_cycles
Note: compartment refers to shelf; container refers to bin; Lock Ring is a name of product;
Question: List the locations ids, compartments and containers for the Lock Ring
SQL: SELECT productinventory.locationid, productinventory.shelf, productinventory.bin FROM product INNER JOIN productinventory ON product.productid = productinventory.productid WHERE product.name LIKE 'Lock Ring'
Database: works_cycles
Note: Road Frames is a name of product subcategory;
Question: What category do Road Frames fall into?
SQL: SELECT productcategory.name FROM productsubcategory INNER JOIN productcategory ON productsubcategory.productcategoryid = productcategory.productcategoryid WHERE productsubcategory.name = 'Road Frames'
Database: works_cycles
Note: handling damage is descrription of manufacturing failure which refers to scrapreason.name;
Question: List all the scraped work orders for handling damage reason.
SQL: SELECT workorder.workorderid FROM scrapreason INNER JOIN workorder ON scrapreason.scrapreasonid = workorder.scrapreasonid WHERE scrapreason.name = 'Handling damage'
Database: works_cycles
Note: profit = SUBTRACT(listprice, standardcost);
Question: What is the profit for the product "792"?
SQL: SELECT productlistpricehistory.listprice - productcosthistory.standardcost FROM productlistpricehistory INNER JOIN productcosthistory ON productlistpricehistory.productid = productcosthistory.productid WHERE productlistpricehistory.productid = 792
Database: works_cycles
Question: Who owns the email address "regina7@adventure-works.com"?
SQL: SELECT person.firstname, person.lastname FROM emailaddress INNER JOIN person ON emailaddress.businessentityid = person.businessentityid WHERE emailaddress.emailaddress = 'regina7@adventure-works.com'
Database: works_cycles
Question: Where are the locations where the product "810" is stored?
SQL: SELECT LOCATION.name FROM productinventory INNER JOIN LOCATION ON productinventory.locationid = LOCATION.locationid WHERE productinventory.productid = 810
Database: works_cycles
Question: What is the name of the product the work order "2540" was making?
SQL: SELECT product.name FROM workorder INNER JOIN product ON workorder.productid = product.productid WHERE workorder.workorderid = 2540
Database: works_cycles
Note: price refers to listprice; price of 3 products = MULTIPLY(listprice, 3); Lock Washer 6 is a name of a product;
Question: What is the price for the AWC Logo Cap?
SQL: SELECT productlistpricehistory.listprice FROM product INNER JOIN productlistpricehistory ON product.productid = productlistpricehistory.productid WHERE product.name = 'AWC Logo Cap'
Database: works_cycles
Note: Down Tube is a name of a product;
Question: List all the work orders that is related to the Down Tube.
SQL: SELECT workorder.workorderid FROM product INNER JOIN workorder ON product.productid = workorder.productid WHERE product.name = 'Down Tube'