Chinastark/bird_dataset huggingface dataset:
Database: ice_hockey_draft
Note: country and nation are synonyms; country where most players come from refers to MaX(COUNT(nation WHERE team = 'plymouth Whalers')); players refers to playername; team plymouth Whalers refers to team = 'plymouth Whalers';
Question: Which country do most players of team Plymouth Whalers come from?
SQL: SELECT t.nation FROM ( SELECT playerinfo.nation, count(playerinfo.eliteid) FROM playerinfo INNER JOIN seasonstatus ON playerinfo.eliteid = seasonstatus.eliteid WHERE seasonstatus.team = 'Plymouth Whalers' GROUP BY playerinfo.nation ORDER BY count(playerinfo.eliteid) DESC LIMIT 1 ) AS t
Database: ice_hockey_draft
Note: who refers to playername; most assists refers to MaX(a); team plymouth Whalers refers to team = 'plymouth Whalers'; 1999-2000 season refers to season = '1999-2000';
Question: Who had the most assists of team Plymouth Whalers in the 1999-2000 season?
SQL: SELECT playerinfo.playername FROM playerinfo INNER JOIN seasonstatus ON playerinfo.eliteid = seasonstatus.eliteid WHERE seasonstatus.team = 'Plymouth Whalers' AND seasonstatus.season = '1999-2000' ORDER BY seasonstatus.a DESC LIMIT 1
Database: ice_hockey_draft
Note: height in inches refers to height_in_inch; players refers to playername; team Oshawa generals refers to team = 'Oshawa generals';
Question: Indicate the height of all players from team Oshawa Generals in inches.
SQL: SELECT height_info.height_in_inch FROM playerinfo INNER JOIN seasonstatus ON playerinfo.eliteid = seasonstatus.eliteid INNER JOIN height_info ON playerinfo.height = height_info.height_id WHERE seasonstatus.team = 'Oshawa Generals'
Database: ice_hockey_draft
Note: oldest player refers to MIN(birthdate); OHL league refers to league = 'OHL'; 1997-2000 season refers to season = '1997-2000';
Question: Who is the oldest player that participated in OHL league in the 1997 - 2000 season?
SQL: SELECT playerinfo.playername FROM playerinfo INNER JOIN seasonstatus ON playerinfo.eliteid = seasonstatus.eliteid WHERE seasonstatus.league = 'OHL' AND seasonstatus.season = '1999-2000' ORDER BY playerinfo.birthdate LIMIT 1
Database: ice_hockey_draft
Note: tallest refers to MaX(height_in_cm);  player refers to playername; team USa U20 refers to team = 'USa U20';
Question: Who is the tallest player in team USA U20?
SQL: SELECT t.playername FROM ( SELECT playerinfo.playername, height_info.height_in_cm FROM playerinfo INNER JOIN seasonstatus ON playerinfo.eliteid = seasonstatus.eliteid INNER JOIN height_info ON playerinfo.height = height_info.height_id WHERE seasonstatus.team = 'USA U20' ORDER BY height_info.height_in_cm DESC ) AS t WHERE t.height_in_cm = ( SELECT max(height_info.height_in_cm) FROM playerinfo INNER JOIN seasonstatus ON playerinfo.eliteid = seasonstatus.eliteid INNER JOIN height_info ON playerinfo.height = height_info.height_id WHERE seasonstatus.team = 'USA U20' )
Database: ice_hockey_draft
Note: percentage = MULTIpLY(DIVIDE(SUM(nation = 'Sweden'), COUNT(eliteid) WHERE season = '1997-2000'), 100); Swedish refers to nation = 'Sweden'; players refers to playername; playoffs games refers to gametype = 'playoffs'; 1997-2000 season refers to 3 consecutive seasons : '1997-1998', '1998-1999', '1999-2000';
Question: What is the percentage of Swedish players in playoffs games in the 1997 - 2000 season?
SQL: SELECT DISTINCT cast(count(CASE WHEN playerinfo.nation = 'Sweden' THEN playerinfo.eliteid ELSE NULL END) OVER (PARTITION BY seasonstatus.season) AS REAL) * 100 / count(playerinfo.eliteid) OVER (PARTITION BY seasonstatus.season) FROM playerinfo INNER JOIN seasonstatus ON playerinfo.eliteid = seasonstatus.eliteid WHERE seasonstatus.season IN ('1997-1998', '1998-1999', '1999-2000')
Database: ice_hockey_draft
Note: percentage = MULTIpLY(DIVIDE(SUM(pim WHERE nation = 'Sweden'), COUNT(eliteid) WHERE league = 'OHL'), 100); Swedish refers to nation = 'Sweden'; players refers to playername; OHL league refers to league = 'OHL';
Question: Calculate the percentage of penalty minutes of Swedish players in OHL league among all players.
SQL: SELECT cast(count(CASE WHEN playerinfo.nation = 'Sweden' THEN seasonstatus.pim ELSE NULL END) AS REAL) * 100 / count(*) FROM playerinfo INNER JOIN seasonstatus ON playerinfo.eliteid = seasonstatus.eliteid WHERE seasonstatus.league = 'OHL'
Database: works_cycles
Note: Average cost = AVG(standardcost);
Question: What is the average standard cost of product number CA-1098?
SQL: SELECT avg(productcosthistory.standardcost) FROM product INNER JOIN productcosthistory ON product.productid = productcosthistory.productid WHERE product.productnumber = 'CA-1098'
Database: works_cycles
Note: The current standard cost refers to enddate is NULL;
Question: For all the products, list the product name and its corresponding start date for the current standard cost.
SQL: SELECT product.name, productcosthistory.startdate FROM product INNER JOIN productcosthistory ON product.productid = productcosthistory.productid WHERE productcosthistory.enddate IS NULL
Database: works_cycles
Note: SUBTRACT(product.standardcost, CostHistory.standardcost)>80;
Question: List the products whereby the standard cost is $80 more than previous standard cost in history.
SQL: SELECT product.name FROM product INNER JOIN productcosthistory ON product.productid = productcosthistory.productid WHERE product.standardcost - productcosthistory.standardcost > 80 GROUP BY product.name
Database: works_cycles
Question: Name all products and total quantity for each item for shopping cart ID 14951.
SQL: SELECT product.name, shoppingcartitem.quantity FROM product INNER JOIN shoppingcartitem ON product.productid = shoppingcartitem.productid WHERE shoppingcartitem.shoppingcartid = 14951
Database: works_cycles
Note: product with more than 5 quantity refers to quantity>5;
Question: List the product name with more than 5 quantity in the shopping cart.
SQL: SELECT product.name FROM product INNER JOIN shoppingcartitem ON product.productid = shoppingcartitem.productid WHERE shoppingcartitem.quantity > 5
Database: works_cycles
Note: Low quality refers to the product's quality class, therefore class = 'L';
Question: For all the purchase order transactions, name all the products with low quality.
SQL: SELECT DISTINCT product.name FROM product INNER JOIN transactionhistory ON product.productid = transactionhistory.productid WHERE product.class = 'L' AND transactionhistory.transactiontype = 'P' ORDER BY product.name
Database: works_cycles
Note: quantity more than 10,000 pieces refers to quantity>10000; selling price refers to listprice;
Question: Provide all the transactions whereby the quantiy is more than 10,000 pieces. State the product name and the selling price.
SQL: SELECT DISTINCT product.name, product.listprice FROM product INNER JOIN transactionhistory ON product.productid = transactionhistory.productid WHERE transactionhistory.quantity > 10000
Database: works_cycles
Note: High quality refers to the product's quality class, therefore class = 'H'; the lowest transacted quantity refers to quantity = 1;
Question: Which is a high quality product but with the lowest transacted quantity?
SQL: SELECT product.name FROM product INNER JOIN transactionhistory ON product.productid = transactionhistory.productid WHERE product.class = 'H' ORDER BY transactionhistory.quantity ASC LIMIT 1
Database: works_cycles
Note: The Mountain line refers to the product line, therefore productline = 'M';
Question: How many transactions are there for product under the Mountain line?
SQL: SELECT count(transactionhistory.transactionid) FROM product INNER JOIN transactionhistory ON product.productid = transactionhistory.productid WHERE product.productline = 'M'
Database: works_cycles
Note: Sales profit = MULTIPLY(SUBTRACT(listprice, standardcost; quantity)), where shoppingcartid = '20621';
Question: How much would be the total sales profit for shopping cart ID 20621 ?
SQL: SELECT sum((product.listprice - product.standardcost) * shoppingcartitem.quantity) FROM product INNER JOIN shoppingcartitem ON product.productid = shoppingcartitem.productid WHERE shoppingcartitem.shoppingcartid = 20621
Database: works_cycles
Note: High quality refers to the product's quality class, therefore class = 'H';
Question: List all product names that are high in quality. Please also state its selling price.
SQL: SELECT name, listprice FROM product WHERE CLASS = 'H'
Database: works_cycles
Note: Saleable product refers to finishedgoodsflag = 1;
Question: Which product line has the most products that are salable?
SQL: SELECT productline FROM product WHERE finishedgoodsflag = 1 GROUP BY productline ORDER BY count(finishedgoodsflag) DESC LIMIT 1
Database: works_cycles
Note: reviewer whose name begin with letter 'J' = reviewername LIKE 'J%';
Question: Provide details of review from reviewer whose name begin with letter 'J'. State the product ID, rating and comments.
SQL: SELECT productid, rating, comments FROM productreview WHERE reviewername LIKE 'J%'
Database: works_cycles
Note: product with the lowest rating refers to the rating given by the reviewer where rating = 1;
Question: State the product name, product line, rating and the selling price of product with the lowest rating.
SQL: SELECT product.name, product.productline, productreview.rating, product.listprice FROM product INNER JOIN productreview ON product.productid = productreview.productid ORDER BY productreview.rating ASC LIMIT 1
Database: works_cycles
Note: Profit = AVG(SUBTRACT(listprice, standardcost)>100;
Question: Calculate the profit of each products. List all products with more than $100 in profit.
SQL: SELECT DISTINCT name FROM product WHERE listprice - standardcost > 100
Database: works_cycles
Note: The Road line refers to the product line, therefore productline = 'R';
Question: List down the product name, reviewer name, rating and comments for product under the road line.
SQL: SELECT product.name, productreview.reviewername, productreview.rating, productreview.comments FROM product INNER JOIN productreview USING (productid) WHERE product.productline = 'R'
Database: works_cycles
Note: AVG(rating) = DIVIDE(SUM(rating), COUNT(reviewername));
Question: How many people reviewed for product named HL Mountain Pedal? What is the average rating?
SQL: SELECT count(product.productid), avg(productreview.rating) FROM product INNER JOIN productreview ON product.productid = productreview.productid WHERE product.name = 'HL Mountain Pedal'
Database: works_cycles
Note: Rejected refers rejected product in which to rejectedqty = 1;
Question: List the purchase order whereby all received quantity were rejected? Name those product.
SQL: SELECT product.name FROM product INNER JOIN purchaseorderdetail ON product.productid = purchaseorderdetail.productid WHERE purchaseorderdetail.rejectedqty = purchaseorderdetail.receivedqty AND purchaseorderdetail.rejectedqty <> 0
Database: works_cycles
Note: product without any rejected quantity refers to rejectedqty = 0;
Question: Among all products without any rejected quantity, which product has the highest line total? State the product name and unit price.
SQL: SELECT product.name, purchaseorderdetail.unitprice FROM product INNER JOIN purchaseorderdetail ON product.productid = purchaseorderdetail.productid WHERE purchaseorderdetail.rejectedqty = 0 ORDER BY purchaseorderdetail.linetotal DESC LIMIT 1
Database: works_cycles
Note: Purchase order with order quantity of 5000 or more refers to orderqty>= 5000;
Question: List all product names and its product line for all purchase order with order quantity of 5000 or more.
SQL: SELECT product.name, product.productline FROM product INNER JOIN purchaseorderdetail ON product.productid = purchaseorderdetail.productid WHERE purchaseorderdetail.orderqty > 4999
Database: works_cycles
Note: The Touring line refers to the product line, therefore productline = 'T';
Question: What is the total ordered quantity for products under the 'Touring' line?
SQL: SELECT sum(purchaseorderdetail.orderqty) FROM product INNER JOIN purchaseorderdetail ON product.productid = purchaseorderdetail.productid WHERE product.productline = 'T'
Database: works_cycles
Note: Low quality refers to the product's quality class, therefore class = 'L';
Question: Among the low quality product, which product has the highest line total? List the product name and its line total?
SQL: SELECT product.name, purchaseorderdetail.linetotal FROM product INNER JOIN purchaseorderdetail ON product.productid = purchaseorderdetail.productid WHERE CLASS = 'L' ORDER BY orderqty * unitprice DESC LIMIT 1
Database: works_cycles
Note: Profit on net = SUBTRACT(lastreceiptcost, standardprice);
Question: Which product has the highest profit on net? State the product name.
SQL: SELECT product.name FROM product INNER JOIN productvendor ON product.productid = productvendor.productid ORDER BY productvendor.lastreceiptcost - productvendor.standardprice DESC LIMIT 1
Database: works_cycles
Note: miinimum order quantity refers to minorderqty = 100;
Question: List all products with minimum order quantity of 100 and order them by product name in descending order.
SQL: SELECT DISTINCT product.name FROM product INNER JOIN productvendor ON product.productid = productvendor.productid WHERE productvendor.minorderqty = 100 ORDER BY product.name DESC
Database: works_cycles
Note: Profit = SUBTRACT(listprice, standardcost); the highest rating in review refers to rating = 5;
Question: List the name and calculate its profit for product with the highest rating in review.
SQL: SELECT product.name, product.listprice - product.standardcost FROM product INNER JOIN productreview ON product.productid = productreview.productid ORDER BY productreview.rating DESC LIMIT 1
Database: works_cycles
Note: Profit = MULTIPLY(SUBTRACT(listprice, standardcost) quantity));
Question: What is the total profit all transactions with product ID 827?
SQL: SELECT sum((product.listprice - product.standardcost) * transactionhistory.quantity) FROM product INNER JOIN transactionhistory ON product.productid = transactionhistory.productid WHERE product.productid = 827
Database: works_cycles
Note: currency pair refers to fromcurrencycode/tocurrencycode;
Question: Which currency pair's average exchange rate for the day is the highest?
SQL: SELECT fromcurrencycode, tocurrencycode FROM currencyrate ORDER BY averagerate DESC LIMIT 1
Database: works_cycles
Note: number of products refers to orderqty;
Question: How many products with the highest unit price were ordered?
SQL: SELECT orderqty FROM purchaseorderdetail ORDER BY unitprice DESC LIMIT 1
Database: works_cycles
Note: United States refers to countryregioncode = 'US';
Question: Between Northwest and Southeast of the United States, which territory one recorded the highest amount of sales last year?
SQL: SELECT name FROM salesterritory WHERE countryregioncode = 'US' AND (name = 'Northwest' OR name = 'Southeast') ORDER BY saleslastyear DESC LIMIT 1
Database: works_cycles
Note: full name = firstname+middlename+Last name; approved document refers to status = 2;
Question: What is the full name of the Document Control Manager who is in charge of all Level 1 approved documents?
SQL: SELECT person.firstname, person.middlename, person.lastname FROM person INNER JOIN employee ON person.businessentityid = employee.businessentityid INNER JOIN document ON document.owner = employee.businessentityid WHERE employee.jobtitle = 'Document Control Manager' AND document.documentlevel = 1 AND document.status = 2 GROUP BY person.firstname, person.middlename, person.lastname
Database: works_cycles
Note: highest subtotal amount of sales order refers to max(subtotal);
Question: Which customer has the highest subtotal amount of sales orders whose assigned to the salesperson with the highest bonus?
SQL: SELECT salesorderheader.customerid FROM salesorderheader INNER JOIN salesperson ON salesorderheader.salespersonid = salesperson.businessentityid ORDER BY salesorderheader.subtotal DESC LIMIT 1
Database: works_cycles
Note: total price = multiply(unitprice, orderqty);
Question: What is the total price of Sales Order ID 46625 with Volume Discount 11 to 14 and Product ID 716?
SQL: SELECT salesorderdetail.unitprice * salesorderdetail.orderqty FROM specialoffer INNER JOIN salesorderdetail ON specialoffer.specialofferid = salesorderdetail.specialofferid WHERE specialoffer.description = 'Volume Discount 11 to 14' AND specialoffer.specialofferid = 2 AND salesorderdetail.productid = 716 AND salesorderdetail.salesorderid = 46625
Database: works_cycles
Note: reorderpoint<600; product is manufactured in-house refers to makeflag = 1;
Question: Of the products that has a reorder inventory point of no more than 600, how many manufactured in-house products that takes 1 day to manufacture with BOM Level 4 are there?
SQL: SELECT count(product.productid) FROM product INNER JOIN billofmaterials ON product.productid = billofmaterials.productassemblyid WHERE product.makeflag = 1 AND product.daystomanufacture = 1 AND billofmaterials.bomlevel = 4 AND product.reorderpoint <= 600
Database: works_cycles
Note: Canada is name of a sales territory;
Question: What is the highest amount of bonus earned by the sales person in Canada?
SQL: SELECT salesperson.bonus FROM salesterritory INNER JOIN salesperson ON salesterritory.territoryid = salesperson.territoryid WHERE salesterritory.countryregioncode = 'CA' ORDER BY salesperson.salesquota DESC LIMIT 1
Database: works_cycles
Note: lowest rating refers to rating = 1;
Question: What are the names of the product that has the lowest rating?
SQL: SELECT product.name FROM productreview INNER JOIN product ON productreview.productid = product.productid WHERE productreview.rating = ( SELECT rating FROM productreview ORDER BY rating ASC LIMIT 1 )
Database: works_cycles
Note: startdate BETWEEN '2009-01-01' AND '2009-12-31';
Question: How many of the workers who started working in 2009 are from the Production Department?
SQL: SELECT count(employeedepartmenthistory.businessentityid) FROM department INNER JOIN employeedepartmenthistory ON department.departmentid = employeedepartmenthistory.departmentid WHERE employeedepartmenthistory.startdate >= '2009-01-01' AND employeedepartmenthistory.startdate < '2010-01-01' AND department.name = 'Production'
Database: works_cycles
Note: full name = firstname+middlename+lastname; highest-paid refers to max(rate); single refers to status = 'S'; female refers to gender = 'F';
Question: Who is the company's highest-paid single female employee? Include her full name and job title.
SQL: SELECT person.firstname, person.middlename, person.lastname, employee.jobtitle FROM employee INNER JOIN employeepayhistory ON employee.businessentityid = employeepayhistory.businessentityid INNER JOIN person ON employeepayhistory.businessentityid = person.businessentityid WHERE employee.maritalstatus = 'S' AND employee.gender = 'F' ORDER BY employeepayhistory.rate DESC LIMIT 1
Database: works_cycles
Note: full name = firstname+middlename+lastname; HiredDate refers to the date the person joins the company;
Question: Who is the Vice President of Engineering and when did he join the company? Indicate his/her full name.
SQL: SELECT person.firstname, person.middlename, person.lastname, employee.hiredate FROM employee INNER JOIN person USING (businessentityid) WHERE employee.jobtitle = 'Vice President of Engineering'
Database: works_cycles
Note: active employee refers to currentflag = 1; rate<= 30;
Question: How many active employees whose payrate is equal or below 30 per hour.
SQL: SELECT count(employee.businessentityid) FROM employee INNER JOIN employeepayhistory ON employee.businessentityid = employeepayhistory.businessentityid WHERE employee.currentflag = 1 AND employeepayhistory.rate <= 30
Database: works_cycles
Note: recently started working refers to latest startdate;
Question: Which department has a worker who just recently started working?
SQL: SELECT department.name FROM department INNER JOIN employeedepartmenthistory ON department.departmentid = employeedepartmenthistory.departmentid ORDER BY employeedepartmenthistory.startdate DESC LIMIT 1
Database: works_cycles
Note: SC is an abbreviation for store Contact; store contact person refers to persontype = 'SC'; recently hired refers to latest startdate;
Question: Which store sales person was reently hired? Indicate his/her full name and gender.
SQL: SELECT person.firstname, person.middlename, person.lastname, employee.gender FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE person.persontype = 'SP'
Database: works_cycles
Note: least number of sick leave refers to min(sickleavehours); payfrequency = 1 means ‘Salary received monthly’; payfrequency = 2 means ‘Salary received biweekly';
Question: How frequently do the employee with the least number of sick leave hours get paid?
SQL: SELECT employeepayhistory.payfrequency FROM employee INNER JOIN employeepayhistory ON employee.businessentityid = employeepayhistory.businessentityid ORDER BY employee.sickleavehours ASC LIMIT 1
Database: works_cycles
Note: lowest pay refers to min(rate);
Question: Which job title has the lowest pay?
SQL: SELECT employee.jobtitle FROM employee INNER JOIN employeepayhistory ON employee.businessentityid = employeepayhistory.businessentityid ORDER BY employeepayhistory.rate ASC LIMIT 1
Database: works_cycles
Question: What is the total number of employees that worked in the Finance department?
SQL: SELECT count(employeedepartmenthistory.businessentityid) FROM department INNER JOIN employeedepartmenthistory USING (departmentid) WHERE department.name = 'Finance'
Database: works_cycles
Note: profit = subtract(listprice, standardcost); the depth the component from its parent refers to bomlevel;
Question: What is the profit of the product with the highest list price and of the product with the lowest list price other than 0? Indicates the depth the component is from its parent.
SQL: SELECT ( SELECT listprice - standardcost FROM product WHERE listprice != 0 ORDER BY listprice DESC LIMIT 1 ) , ( SELECT listprice - standardcost FROM product WHERE listprice != 0 ORDER BY listprice LIMIT 1 )
Database: works_cycles
Note: above average credit rating refers to creditrating = 3; profit on net = subtract(lastreceiptcost, standardprice);
Question: Among the companies to which Adventure Works Cycles purchases parts or other goods, what is the profit on net obtained from the vendor who has an above average credit rating? Kindly indicate each names of the vendor and the corresponding net profits.
SQL: SELECT vendor.name, productvendor.lastreceiptcost - productvendor.standardprice FROM productvendor INNER JOIN vendor ON productvendor.businessentityid = vendor.businessentityid WHERE vendor.creditrating = 3
Database: works_cycles
Note: address that is too long refers to addressline2! = null;
Question: How many accounts have an address that is too long?
SQL: SELECT count(*) FROM address WHERE addressline2 <> ''
Database: works_cycles
Note: account latest updated refers to year(modifieddate) = 2022 and month(modifieddate) = 10;
Question: What is the postal code of the street address of the account that is latest updated?
SQL: SELECT postalcode FROM address ORDER BY modifieddate DESC LIMIT 1
Database: works_cycles
Note: longest assembly item duration = max(subtract(enddate,startdate));
Question: What is the longest assembly item duration for bicycles?
SQL: SELECT julianday(enddate) - julianday(startdate) FROM billofmaterials ORDER BY julianday(enddate) - julianday(startdate) DESC LIMIT 1
Database: works_cycles
Note: assembly lines that are not finished refers to enddate = null;
Question: How many assembly items for bicycles aren't finished?
SQL: SELECT count(billofmaterialsid) FROM billofmaterials WHERE enddate IS NULL
Database: works_cycles
Note: greatest need in quantity refers to max(perassemblyqty);
Question: Please list the unit measure code of the component that is of the greatest need in quantity to create the assembly.
SQL: SELECT unitmeasurecode FROM billofmaterials ORDER BY perassemblyqty DESC LIMIT 1
Database: works_cycles
Note: product maintenance documents are private refers to documentsummary = null;
Question: How many product maintenance documents are private?
SQL: SELECT count(documentnode) FROM document WHERE documentsummary IS NULL