Chinastark/bird_dataset huggingface dataset:
Database: works_cycles
Note: evening shift also means night shift where name = 'Night';most personnel in evening shift refers to Max(Count(shift.shiftid(name = 'Night')));
Question: Which department, altogether, has the most personnel who work the evening shift?
SQL: SELECT department.name FROM employeedepartmenthistory INNER JOIN shift ON employeedepartmenthistory.shiftid = shift.shiftid INNER JOIN department ON employeedepartmenthistory.departmentid = department.departmentid WHERE shift.name = 'Night' GROUP BY department.name ORDER BY count(employeedepartmenthistory.businessentityid) DESC LIMIT 1
Database: works_cycles
Note: shipment by truck refers to name = 'XRQ - TRUCK GROUND';
Question: How many shipments by truck were made?
SQL: SELECT count(*) FROM shipmethod INNER JOIN salesorderheader USING (shipmethodid) WHERE shipmethod.name = 'XRQ - TRUCK GROUND'
Database: works_cycles
Note: order refers to salesorderid;
Question: What are the sales reasons for order 43718?
SQL: SELECT salesreason.name FROM salesorderheadersalesreason INNER JOIN salesreason ON salesorderheadersalesreason.salesreasonid = salesreason.salesreasonid WHERE salesorderheadersalesreason.salesorderid = 43718
Database: works_cycles
Note: bikes is product category;
Question: What bike subcategories are there?
SQL: SELECT productsubcategory.name FROM productsubcategory INNER JOIN productcategory ON productsubcategory.productcategoryid = productcategory.productcategoryid WHERE productcategory.name = 'Bikes'
Database: works_cycles
Note: highest yearly sales quota refers to Max(salesquota);
Question: Which sales areas are expected to have the highest yearly sales quota?
SQL: SELECT salesterritory.name FROM salesperson INNER JOIN salesterritory ON salesperson.territoryid = salesterritory.territoryid GROUP BY salesperson.territoryid ORDER BY sum(salesperson.salesquota) DESC LIMIT 1
Database: works_cycles
Note: goods refers to products;
Question: What goods were sold to customers in accordance with sales order number 43660?
SQL: SELECT product.name FROM product INNER JOIN salesorderdetail ON product.productid = salesorderdetail.productid WHERE salesorderdetail.salesorderid = 43660
Database: works_cycles
Note: most order refers to Max(orderqty);
Question: Please list the top 5 products with the most orders.
SQL: SELECT product.name FROM product INNER JOIN salesorderdetail ON product.productid = salesorderdetail.productid GROUP BY product.name ORDER BY sum(salesorderdetail.orderqty) DESC LIMIT 0, 5
Database: works_cycles
Note: shelves refer to shelf; down tube is a product;
Question: Where are the shelves where the down tube product was stored?
SQL: SELECT productinventory.shelf FROM product INNER JOIN productinventory ON product.productid = productinventory.productid WHERE product.name = 'Down Tube'
Database: works_cycles
Note: Fun Toys and Bikes is name of a store;
Question: Which address type does "Fun Toys and Bikes" fall under?
SQL: SELECT addresstype.name FROM businessentityaddress INNER JOIN addresstype ON businessentityaddress.addresstypeid = addresstype.addresstypeid INNER JOIN store ON businessentityaddress.businessentityid = store.businessentityid WHERE store.name = 'Fun Toys and Bikes'
Database: works_cycles
Note: Next-Door Bike store is name of a store;
Question: Who is the "Next-Door Bike Store" point of contact?
SQL: SELECT contacttype.name FROM contacttype INNER JOIN businessentitycontact ON contacttype.contacttypeid = businessentitycontact.contacttypeid INNER JOIN store ON businessentitycontact.businessentityid = store.businessentityid WHERE store.name = 'Next-Door Bike Store'
Database: works_cycles
Note: Order Reference Number refers to referenceorderid;
Question: What is the order reference number for the "Mountain End Caps" product?
SQL: SELECT transactionhistory.referenceorderid FROM product INNER JOIN transactionhistory ON product.productid = transactionhistory.productid WHERE product.name = 'Mountain End Caps'
Database: works_cycles
Note: 12th business refers to businessentityid = 12;
Question: What is the 12th business's first line address?
SQL: SELECT address.addressline1 FROM address INNER JOIN businessentityaddress ON address.addressid = businessentityaddress.addressid WHERE businessentityaddress.businessentityid = 12
Database: works_cycles
Note: business with ther ID refers to businessentityid;
Question: Please list any three businesses with their IDs that are located in Dallas City.
SQL: SELECT businessentityaddress.businessentityid FROM address INNER JOIN businessentityaddress ON address.addressid = businessentityaddress.addressid WHERE address.city = 'Dallas' LIMIT 3
Database: works_cycles
Note: Racine is a city;
Question: What is the name of the state that Racine belongs to?
SQL: SELECT stateprovince.name FROM address INNER JOIN stateprovince ON address.stateprovinceid = stateprovince.stateprovinceid WHERE address.city = 'Racine'
Database: works_cycles
Note: Arabic and Thai are language names refers to name = 'Arabic'and name = 'Thai'; Differencce in percentage = Subtract(((Count(cultureid(name = 'Arabic'))/Count(cultureid))*100),((Count(cultureid(name = 'Thai'))/Count(cultureid))*100)));
Question: What is the difference in percentage between the product descriptions written in Arabic and Thai?
SQL: SELECT cast(sum(CASE WHEN culture.name = 'Arabic' THEN 1 ELSE 0 END) AS REAL) * 100 / sum(CASE WHEN culture.name = 'Thai' THEN 1 ELSE 0 END) FROM culture INNER JOIN productmodelproductdescriptionculture ON culture.cultureid = productmodelproductdescriptionculture.cultureid
Database: works_cycles
Note: Northwest refers to name = 'Northwest'; US refers to countryregioncode = 'US'; forecasted annual sales of above 300,000 refers to salesquota >300000; Percentage = Divide(Count(territoryid(salesquota >300000)),Count(territoryid))*100;
Question: What percentage of businesses in the Northwest US have forecasted annual sales of above 300,000?
SQL: SELECT cast(sum(CASE WHEN salesperson.salesquota > 300000 THEN 1 ELSE 0 END) AS REAL) * 100 / count(salesperson.businessentityid) FROM salesperson INNER JOIN salesterritory ON salesperson.territoryid = salesterritory.territoryid WHERE salesterritory.countryregioncode = 'US' AND salesterritory.name = 'Northwest'
Database: works_cycles
Note: net profit = Subtract(lastreceiptcost, standardprice);
Question: What is the Crankarm product's net profit?
SQL: SELECT productvendor.lastreceiptcost - productvendor.standardprice FROM product INNER JOIN productvendor ON product.productid = productvendor.productid WHERE product.name LIKE '%Crankarm%'
Database: works_cycles
Note: highest review score refers to rating = 5;
Question: What is the name of the product with the almost highest review score?
SQL: SELECT product.name FROM product INNER JOIN productreview ON product.productid = productreview.productid WHERE productreview.rating = ( SELECT rating FROM productreview ORDER BY rating DESC LIMIT 1 )
Database: works_cycles
Note: salary received monthly refers to payfrequency = 1; highest salary per hour refers to Max(rate);
Question: What is the company's second highest salary per hour for employees who are paid monthly?
SQL: SELECT rate FROM employeepayhistory WHERE payfrequency = 1 ORDER BY rate DESC LIMIT 1, 1
Database: works_cycles
Note: Vista Card refers to cardtype = 'Vista'; expire before the year 2007 refers to expyear<= 2006;
Question: How many Vista cards expired before the year 2007?
SQL: SELECT count(creditcardid) FROM creditcard WHERE cardtype = 'Vista' AND expyear < 2007
Database: works_cycles
Note: Night shift refers to name = 'Night';
Question: What time does the company's night shift begin? Indicate the answer in regular form.
SQL: SELECT starttime FROM shift WHERE name = 'Night'
Database: works_cycles
Note: weight in pounds refers to weightunitmeasurecode = 'LB';
Question: What is the weight in pounds of the style that is produced the most by the company? If there are multiple products sharing the same weight, indicate the name of each one of them and their corresponding weights.
SQL: SELECT weight FROM product WHERE weightunitmeasurecode = 'LB' GROUP BY weight ORDER BY count(style) DESC LIMIT 1
Database: works_cycles
Note: greatest difference in sales from previous year to this year refers to Max(Subtract(saleslastyear,salesytd));
Question: Which territory has the greatest difference in sales from previous year to this year? Indicate the difference, as well as the name and country of the region.
SQL: SELECT saleslastyear - salesytd, name, countryregioncode FROM salesterritory ORDER BY saleslastyear - salesytd DESC LIMIT 1
Database: works_cycles
Note: in centimeter refers to sizeunitmeasurecode = 'CM';
Question: What are the names of the top 6 products that has the biggest size in centimeter and what are its reorder point?
SQL: SELECT name, reorderpoint FROM product WHERE sizeunitmeasurecode = 'CM' ORDER BY SIZE DESC LIMIT 6
Database: works_cycles
Note: amount to be paid refers to totaldue;
Question: How much is the amount to be paid by the company for the purchase order with the third highest freight amount?
SQL: SELECT totaldue FROM purchaseorderheader ORDER BY freight DESC LIMIT 2, 1
Database: works_cycles
Note: Lightest product refers to Min(weight); profit if they sell 10 items refers to Subtract (listprice , standardcost) *10;
Question: What profit will the company gain if they sell 10 items of the product that has the lightest weight?
SQL: SELECT 10 * (listprice - standardcost) FROM product WHERE weight IS NOT NULL ORDER BY weight LIMIT 1
Database: works_cycles
Note: tax amount refers to taxamt; biggest tax amount refers to MAX(taxamt);
Question: How much is the tax amount of the purchase order with the biggest tax amount? Indicate the purchase order ID.
SQL: SELECT taxamt, purchaseorderid FROM purchaseorderheader ORDER BY taxamt DESC LIMIT 1
Database: works_cycles
Note: projected yearly sales refers to salesquota; salesquota<= 50000;
Question: How many person have a projected yearly sales of no more than 50,000?
SQL: SELECT count(businessentityid) FROM salespersonquotahistory WHERE salesquota < 500000
Database: works_cycles
Note: oldest employee born before 1969 refers to year(birthdate)<'1969';
Question: Among the employees who were born before 1969, what is the work shift of the 6th oldest employee?
SQL: SELECT shift.starttime, shift.endtime FROM employee INNER JOIN employeedepartmenthistory ON employee.businessentityid = employeedepartmenthistory.businessentityid INNER JOIN shift ON employeedepartmenthistory.shiftid = shift.shiftid WHERE strftime('%Y', employee.birthdate) < '1969' ORDER BY employee.birthdate LIMIT 5, 1
Database: works_cycles
Note: profit on a single item = SUBTRACT(listprice, standardcost); length of time to manufacture refers to daystomanufacture; fastest to manucature refers to MIN(daystomanufacture);
Question: Which product allows the company to make the highest profit on a single item among those that are the fastest to manufacture? Indicate the rating of the product if there any.
SQL: SELECT product.name, productreview.rating FROM product INNER JOIN productreview ON product.productid = productreview.productid WHERE product.daystomanufacture = ( SELECT daystomanufacture FROM product ORDER BY daystomanufacture LIMIT 1 ) ORDER BY product.listprice - product.standardcost DESC LIMIT 1
Database: works_cycles
Note: full name = firstname+middlename+lastname; bonus<1000;
Question: What are the full names of the sales person whose bonuses are less than 1,000?
SQL: SELECT person.firstname, person.middlename, person.lastname FROM salesperson INNER JOIN person ON salesperson.businessentityid = person.businessentityid WHERE salesperson.bonus < 1000
Database: works_cycles
Note: Senior Tool Designer is a jobtitle; 33 years old at the time of hiring refers to SUBTRACT(year(hiredate)), (year(birthdate)) = 33;
Question: When did the Senior Tool Designer, who was 33 years old at the time he was hired, stopped working in the Engineering department?
SQL: SELECT employeedepartmenthistory.enddate FROM employee INNER JOIN employeedepartmenthistory ON employee.businessentityid = employeedepartmenthistory.businessentityid INNER JOIN department ON employeedepartmenthistory.departmentid = department.departmentid WHERE employee.jobtitle = 'Senior Tool Designer' AND strftime('%Y', employee.hiredate) - strftime('%Y', employee.birthdate) = 33 AND employeedepartmenthistory.enddate IS NOT NULL
Database: works_cycles
Note: average credit rating refers to creditrating = 4;  vendor that isn't preferrerd if another vendor is available refers to preferredvendorstatus = 0; SUM(totaldue);
Question: Among the vendors with an average credit rating, what is the overall total due amount of purchases made by the company to the vendor that isn't preferrerd if another vendor is available?
SQL: SELECT sum(purchaseorderheader.totaldue) FROM vendor INNER JOIN purchaseorderheader ON vendor.businessentityid = purchaseorderheader.vendorid WHERE vendor.creditrating = 4 AND vendor.preferredvendorstatus = 0
Database: works_cycles
Note: most number of night shift = MAX(count(shift.name = 'Night'));
Question: Which department has the most number of night shifts?
SQL: SELECT department.name FROM shift INNER JOIN employeedepartmenthistory ON shift.shiftid = employeedepartmenthistory.shiftid INNER JOIN department ON employeedepartmenthistory.departmentid = department.departmentid GROUP BY employeedepartmenthistory.departmentid ORDER BY count(shift.name = 'Night') DESC LIMIT 1
Database: works_cycles
Note: high class refers to class = 'H"; road bikes is a name of product subcategory; profit = (MULTIPLY(SUBTRACT(listprice, standardcost)), (2)));
Question: How much profit can the company gained from selling two high class black Road Bikes with a size of 58?
SQL: SELECT 2 * (product.listprice - product.standardcost) FROM product INNER JOIN productsubcategory ON product.productsubcategoryid = productsubcategory.productsubcategoryid WHERE product.class = 'H' AND product.color = 'Black' AND product.size = 58 AND productsubcategory.name = 'Road Bikes'
Database: works_cycles
Note: youngest refers to latest birthdate; married refers to maritalstatus = 'M'; production technician is a jobtitle; full name = firstname+middlename+lastname;
Question: What are the full names of the 10 youngest married male production technicians?
SQL: SELECT person.firstname, person.middlename, person.lastname FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE employee.jobtitle LIKE 'Production Technician%' AND employee.gender = 'M' AND employee.maritalstatus = 'M' ORDER BY employee.birthdate DESC LIMIT 10
Database: works_cycles
Note: profit on net = SUBTRACT(lastreceiptcost, standardprice);
Question: Among the products with an average lead time of 60, which vendor has the highest profit on net? Indicate the credit rating of such vendor.
SQL: SELECT vendor.name, vendor.creditrating FROM productvendor INNER JOIN vendor ON productvendor.businessentityid = vendor.businessentityid WHERE productvendor.averageleadtime = 60 ORDER BY productvendor.lastreceiptcost - productvendor.standardprice DESC LIMIT 1
Database: works_cycles
Note: maximum orders refers to maxorderqty; maxorderqty = 200; profit on net = SUBTRACT(lastreceiptcost, standardprice);
Question: What is the profit on net of the products that have exactly 200 maximum order quantity? Indicate the name of the vendors to which these products were purchased from.
SQL: SELECT productvendor.lastreceiptcost - productvendor.standardprice, vendor.name FROM productvendor INNER JOIN vendor ON productvendor.businessentityid = vendor.businessentityid WHERE productvendor.maxorderqty = 200
Database: works_cycles
Note: non-sales employee refers to persontype = 'EM'; rejected purchase order refers to status = 3;
Question: What is the full name of the non-sales employee who made the most number of rejected purchase orders?
SQL: SELECT person.firstname, person.lastname FROM purchaseorderheader INNER JOIN person ON purchaseorderheader.employeeid = person.businessentityid WHERE person.persontype = 'EM' AND purchaseorderheader.status = 3 GROUP BY person.firstname, person.lastname ORDER BY count(purchaseorderheader.purchaseorderid) DESC LIMIT 1
Database: works_cycles
Note: minimum order quantity refers to minorderqty;
Question: What are the names of the vendor with the second lowest minimum order quantity?
SQL: SELECT vendor.name FROM productvendor INNER JOIN vendor ON productvendor.businessentityid = vendor.businessentityid ORDER BY productvendor.maxorderqty ASC LIMIT 1, 1
Database: works_cycles
Note: vendors that are no longer used by the company refers to activeflag = 0;
Question: How much are the minimum orders of the vendors that are no longer used by the company?
SQL: SELECT productvendor.minorderqty FROM vendor INNER JOIN productvendor ON vendor.businessentityid = productvendor.businessentityid WHERE vendor.activeflag = 0 ORDER BY productvendor.minorderqty LIMIT 1
Database: works_cycles
Note: vacationhours<10; age at the time of being hired = SUBTRACT(year(hiredate), year(birthdate)); full name = firstname+middlename+lastname;
Question: Of the employees whose vacation hours are no more than 10, what is the age of the oldest employee at the time he/she was hired? Indicate his/her full name.
SQL: SELECT strftime('%Y', employee.hiredate) - strftime('%Y', employee.birthdate), person.firstname, person.middlename, person.lastname FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE employee.vacationhours <= 10 ORDER BY strftime('%Y', employee.hiredate) - strftime('%Y', employee.birthdate) DESC LIMIT 1
Database: works_cycles
Note: primary type refers to persontype; single refers to maritalstatus = 'S"; female refers to gender = 'F'; hiredate BETWEEN '2010-1-1'AND '2010-12-31';
Question: What is the primary type of all single female employees hired between 1/1/2008 to 12/31/2008?
SQL: SELECT person.persontype FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE employee.gender = 'F' AND employee.maritalstatus = 'S' AND strftime('%Y-%m-%d', employee.hiredate) BETWEEN '2008-1-1' AND '2008-12-31' GROUP BY person.persontype ORDER BY count(person.persontype) DESC LIMIT 1
Database: works_cycles
Note: profit on net on a single product = SUBTRACT(listprice, standardcost); second highest rating refers to rating = 4; David is the reviewername;
Question: What is the company's profit on the product that was rated second-highest by David?
SQL: SELECT product.listprice - product.standardcost FROM productreview INNER JOIN product ON productreview.productid = product.productid WHERE productreview.reviewername = 'David' ORDER BY productreview.rating DESC LIMIT 1
Database: works_cycles
Note: geographic area to which the city belong refers to group;
Question: Which geographic area does the city with the second lowest tax rate belongs to? Indicate the name of the state or province as well.
SQL: SELECT salesterritory.'Group', stateprovince.name FROM salestaxrate INNER JOIN stateprovince ON salestaxrate.stateprovinceid = stateprovince.stateprovinceid INNER JOIN salesterritory ON stateprovince.territoryid = salesterritory.territoryid ORDER BY salestaxrate.taxrate LIMIT 1, 1
Database: works_cycles
Note: low class refers to class = 'L'; universal refers to style = 'U'; road frame is a name of product subcategory; average profit = AVG(SUBTRACT(listprice, standardcost);
Question: What is the average profit of all the low class universal road frames? Indicate how many variety of sizes are there and the available colors.
SQL: SELECT avg(product.listprice - product.standardcost), count(DISTINCT product.size) , count(DISTINCT product.style) FROM product INNER JOIN productsubcategory ON product.productsubcategoryid = productsubcategory.productsubcategoryid WHERE product.class = 'L' AND productsubcategory.name = 'Road Frames' GROUP BY product.class, product.color
Database: works_cycles
Note: discount percentage refers to discountpct; LL Road Frame Sale is a description of special offer;
Question: What is the discount percentage of "LL Road Frame Sale"?
SQL: SELECT discountpct FROM specialoffer WHERE description = 'LL Road Frame Sale'
Database: works_cycles
Note: discount refers to discountpct; Excess Inventory is a type of special offer;
Question: How many discount are of the type "Excess Inventory"?
SQL: SELECT count(specialofferid) FROM specialoffer WHERE TYPE = 'Excess Inventory'
Database: works_cycles
Note: seasonal discount is a type of special offer; discount percentage refers to discountpct; highest discount percentage refers to MAX(discountpct);
Question: Which seasonal discount had the highest discount percentage?
SQL: SELECT description FROM specialoffer WHERE TYPE = 'Seasonal Discount' ORDER BY discountpct DESC LIMIT 1
Database: works_cycles
Note: discount percentage refers to discountpct; highest discount percentage refers to MAX(discountpct);
Question: Please list the top 3 discounts with the highest discount percentage and fall under the reseller category.
SQL: SELECT description, discountpct FROM specialoffer WHERE category = 'Reseller' ORDER BY discountpct DESC LIMIT 0, 3
Database: works_cycles
Note: Valley Bicycle Specialists is a name of a store;
Question: Where can I get the demographic information about the Valley Bicycle Specialists store?
SQL: SELECT demographics FROM store WHERE name = 'Valley Bicycle Specialists'
Database: works_cycles
Note: product is mnanufactured in-house refers to makeflag = 1; salable product refers to finishedgoodsflag = 1;
Question: Among all the products that are manufactured in-house, how many of them are salable?
SQL: SELECT sum(finishedgoodsflag) FROM product WHERE makeflag = 1
Database: works_cycles
Note: minimum inventory quantity refers to safetystocklevel; chainring bolts is a name of product;
Question: What is the minimum inventory quantity of Chainring Bolts?
SQL: SELECT safetystocklevel FROM product WHERE name = 'Chainring Bolts'
Database: works_cycles
Question: Which product has the highest standard cost?
SQL: SELECT name FROM product ORDER BY standardcost DESC LIMIT 1
Database: works_cycles
Note: type of employee refers to persontype;
Question: What type of employee is David Bradley?
SQL: SELECT persontype FROM person WHERE firstname = 'David' AND lastname = 'Bradley'
Database: works_cycles
Note: store contact refers to persontype = 'SC';
Question: Among the employees who are store contacts, how many of them have a title of "Mr."?
SQL: SELECT count(businessentityid) FROM person WHERE persontype = 'SC' AND title = 'Mr.'
Database: works_cycles
Note: Valley Bicycle Specialists is a name of store; full address = addressline1+addressline2;
Question: Where can I find the Valley Bicycle Specialists store?
SQL: SELECT address.addressline1, address.addressline2 FROM businessentityaddress INNER JOIN address ON businessentityaddress.addressid = address.addressid INNER JOIN store ON businessentityaddress.businessentityid = store.businessentityid WHERE store.name = 'Valley Bicycle Specialists'
Database: works_cycles
Question: To which e-mail address should I write if I want to contact David Bradley?
SQL: SELECT emailaddress.emailaddress FROM person INNER JOIN emailaddress ON person.businessentityid = emailaddress.businessentityid WHERE person.firstname = 'David' AND person.lastname = 'Bradley'
Database: works_cycles
Note: store contact refers to persontype = 'SC';
Question: Please list the phone numbers of all the store contacts.
SQL: SELECT personphone.phonenumber FROM person INNER JOIN personphone ON person.businessentityid = personphone.businessentityid WHERE person.persontype = 'SC'
Database: works_cycles
Note: hashed password refers to passwordhash;
Question: What is the hashed password of David Bradley?
SQL: SELECT password.passwordhash FROM person INNER JOIN password ON person.businessentityid = password.businessentityid WHERE person.firstname = 'David' AND person.lastname = 'Bradley'