Chinastark/bird_dataset huggingface dataset:
Database: works_cycles
Question: Show me the phone number of Gerald Patel's.
SQL: SELECT personphone.phonenumber FROM person INNER JOIN personphone ON person.businessentityid = personphone.businessentityid WHERE person.firstname = 'Gerald' AND person.lastname = 'Patel'
Database: works_cycles
Question: Which is Business Entity ID No.13626's phone number type?
SQL: SELECT phonenumbertype.name FROM personphone INNER JOIN phonenumbertype USING (phonenumbertypeid) WHERE personphone.businessentityid = 13626
Database: works_cycles
Question: What's Lynn N Tsoflias's job title?
SQL: SELECT employee.jobtitle FROM person INNER JOIN employee ON person.businessentityid = employee.businessentityid WHERE person.firstname = 'Lynn' AND person.middlename = 'N' AND person.lastname = 'Tsoflias'
Database: works_cycles
Note: Bike refers to the name of the product category, therefore productcategoryid = 1;
Question: What is the number of the sub categories for bikes?
SQL: SELECT count(*) FROM productcategory INNER JOIN productsubcategory ON productcategory.productcategoryid = productsubcategory.productcategoryid WHERE productcategory.name = 'Bikes'
Database: works_cycles
Note: document Control Assistant refers  to the  jobtitle = 'document Control Assistant'; hired on 2009/1/22 means the person's hiring date is hiredate = '2009-01-22'; private documents indicate that documentsummary is null; DIVIDE(COUNT(documentsummary is null), COUNT(documentsummary))*100;
Question: For the document Control Assistant who was hired on 2009/1/22, what is the percentage of private documents did he/she have?
SQL: SELECT cast(sum(CASE WHEN document.documentsummary IS NOT NULL THEN 1 ELSE 0 END) AS REAL) / count(document.documentsummary) FROM document INNER JOIN employee ON document.owner = employee.businessentityid WHERE employee.jobtitle = 'Document Control Assistant' AND employee.hiredate = '2009-01-22'
Database: works_cycles
Note: HL Grip Tape refers to the product name; DIVIDE(SUBTRACT(lastreceiptcost, standardprice)), (standardprice) as profit_ratio;
Question: How much is HL Grip Tape's profit ratio?
SQL: SELECT (productvendor.lastreceiptcost - productvendor.standardprice) / productvendor.standardprice FROM productvendor INNER JOIN product ON productvendor.productid = product.productid WHERE product.name = 'HL Grip Tape'
Database: works_cycles
Note: Cellphone referes to the name of the phone type, therefore phonenumbertypeid = 1; DIVIDE(COUNT(phonenumbertypeid = 1), (COUNT(phonenumbertypeid)) as percentage;
Question: For all phone numbers, what percentage of the total is cell phone?
SQL: SELECT cast(sum(CASE WHEN phonenumbertype.name = 'Cell' THEN 1 ELSE 0 END) AS REAL) * 100 / count(phonenumbertype.name) FROM personphone INNER JOIN phonenumbertype ON personphone.phonenumbertypeid = phonenumbertype.phonenumbertypeid
Database: works_cycles
Note: Per assembly quantity of more than 10 is expresses as perassemblyqty>10;
Question: What are the product assembly ID that come with unit measure code EA and BOM level of 2, at the same time have per assembly quantity of more than 10?
SQL: SELECT productassemblyid FROM billofmaterials WHERE unitmeasurecode = 'EA' AND bomlevel = 2 AND perassemblyqty > 10
Database: works_cycles
Note: actual resource hours of 2 refers to actualresourcehrs = 2;
Question: How many location IDs have actual resource hours of 2?
SQL: SELECT count(locationid) FROM workorderrouting WHERE actualresourcehrs = 2
Database: works_cycles
Note: Stocked quantity refers to stockedqty;
Question: What is the stocked quantity of products manufactured from location ID 40?
SQL: SELECT count(*) FROM workorderrouting INNER JOIN billofmaterials ON workorderrouting.locationid = billofmaterials.productassemblyid INNER JOIN workorder ON workorder.workorderid = workorderrouting.workorderid WHERE workorderrouting.locationid = 40
Database: works_cycles
Note: Pre assembly quantity refers to perassemblyqty;
Question: What are the total per assembly quantity for unit measure code EA, IN and OZ respectively? What are the name of these 3 code?
SQL: SELECT sum(billofmaterials.perassemblyqty), unitmeasure.name FROM billofmaterials INNER JOIN unitmeasure ON billofmaterials.unitmeasurecode = unitmeasure.unitmeasurecode WHERE billofmaterials.unitmeasurecode IN ('EA', 'IN', 'OZ') GROUP BY unitmeasure.name
Database: works_cycles
Note: Do not have any work order ID means workorderid is null;
Question: Which product ID do not have any work order ID?
SQL: SELECT productid FROM product WHERE productid NOT IN ( SELECT product.productid FROM product INNER JOIN workorder ON product.productid = workorder.productid )
Database: works_cycles
Question: What is the name of product purchased with transaction type P?
SQL: SELECT productid FROM product WHERE productid IN ( SELECT productid FROM transactionhistory WHERE transactiontype = 'P' )
Database: works_cycles
Note: Accountants refers to jobtitle = 'Accountant'; full name includes firstname, lastname, and middlename;
Question: State the full name of accountants in the company.
SQL: SELECT person.firstname, person.middlename, person.lastname FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE employee.jobtitle = 'Accountant'
Database: works_cycles
Note: Job position refers to jobtitle;
Question: What is the job position currently occupied by Ken J SÃ¡nchez?
SQL: SELECT employee.jobtitle FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE person.firstname = 'Ken' AND person.middlename = 'J' AND person.lastname = 'Sánchez'
Database: works_cycles
Note: Male refers to gender = 'M'; employees do not wish to receive any e-mail promotions are marked as emailpromotion = 0;
Question: How many male employees do not wish to receive e-mail promotion?
SQL: SELECT count(employee.businessentityid) FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE person.emailpromotion = 0 AND employee.gender = 'M'
Database: works_cycles
Note: 2013 refers to quotadate = '2013'; DIVIDE(saleslastyear), (SUM(salesquota where YEAR(quotadate) = 2013)) as percentage;
Question: Who is the top sales person who achived highest percentage of projected sales quota in 2013?
SQL: SELECT businessentityid FROM salesperson WHERE businessentityid IN ( SELECT businessentityid FROM salespersonquotahistory WHERE strftime('%Y', quotadate) = '2013' ) ORDER BY cast(saleslastyear AS REAL) / salesquota DESC LIMIT 1
Database: works_cycles
Note: Married refers to maritalstatus = 'M';  non-sales employees refer to persontype = 'EM';
Question: How many of the non-sales employees are married?
SQL: SELECT count(employee.businessentityid) FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE person.persontype = 'EM' AND employee.maritalstatus = 'M'
Database: works_cycles
Note: production Technicians refer to the  jobtitle = 'production Technician%'; single refers to maritalstatus = 'S'; vendor contact refers to persontype = 'VC';
Question: Among the Production Technicians who are single, how many of them are vendor contact?
SQL: SELECT count(employee.businessentityid) FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE employee.jobtitle LIKE 'Production Technician%' AND employee.maritalstatus = 'S' AND person.persontype = 'VC'
Database: works_cycles
Note: employees who do not wish to receive any e-mail promotions are marked as emailpromotion = 0;
Question: What is the total sick leave hours of employees who do not wish to receive any e-mail promotion?
SQL: SELECT sum(employee.sickleavehours) FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE person.emailpromotion = 0
Database: works_cycles
Note: Sales people refer to persontype = 'SP'; hired prior to 2010 means the person's hiring date was before 2010, therefore year(hiredate)<2010;
Question: Among the sales people, who are hired prior to 2010?
SQL: SELECT count(employee.businessentityid) FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE person.persontype = 'SP' AND substr(employee.hiredate, 0, 4) < 2010
Database: works_cycles
Note: Sales people refer to persontype = 'SP'; projected yearly sales refers to salesquota;
Question: Which sales person achieved the highest sales YTD? What is the projected yearly sales quota in 2011 for this person?
SQL: SELECT salesperson.businessentityid, sum(salesperson.salesquota) FROM salesperson INNER JOIN salespersonquotahistory ON salesperson.businessentityid = salespersonquotahistory.businessentityid WHERE strftime('%Y', salespersonquotahistory.quotadate) = '2011' GROUP BY salesperson.businessentityid ORDER BY sum(salesperson.salesytd) DESC LIMIT 1
Database: works_cycles
Note: Alex refers to firstname = 'Alex'; single refers to maritalstatus = 'S';
Question: How many people with the name Alex are single and occupying organization level of 1?
SQL: SELECT count(employee.businessentityid) FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE person.firstname = 'Alex' AND employee.maritalstatus = 'S' AND employee.organizationlevel = 1
Database: works_cycles
Note: store Contact refers persontype = 'SC'; AVG(vacationhours;
Question: What is the average vacation hours taken by Sales person?
SQL: SELECT cast(sum(employee.vacationhours) AS REAL) / count(employee.businessentityid) FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE person.persontype = 'SP'
Database: works_cycles
Note: The owner refers to businessentityid;
Question: State the last name and job title of owner for document "Crank Arm and Tire Maintenance".
SQL: SELECT person.lastname, employee.jobtitle FROM person INNER JOIN document ON person.businessentityid = document.owner INNER JOIN employee ON person.businessentityid = employee.businessentityid WHERE document.title = 'Crank Arm and Tire Maintenance'
Database: works_cycles
Note: Do not have any suffix means suffix is null;
Question: How many employees do not have any suffix and what are their organization level?
SQL: SELECT count(t3.businessentityid) FROM ( SELECT employee.businessentityid FROM employee INNER JOIN person USING (businessentityid) WHERE person.suffix IS NULL GROUP BY employee.businessentityid ) AS t3
Database: works_cycles
Note: projected sales quota refers to salesquota; projected sales quota in 2013 refers to year(quotadate) = 2013;
Question: Among the sales people who achieved projected sales quota 2013, is there any person from territory ID 1? If yes, state the business entity ID.
SQL: SELECT DISTINCT salesperson.businessentityid FROM salesperson INNER JOIN salespersonquotahistory ON salesperson.businessentityid = salespersonquotahistory.businessentityid WHERE salesperson.territoryid = 1 AND strftime('%Y', quotadate) = '2013'
Database: works_cycles
Note: employees that submitted resume to Human Resource department and got hired refers to BusinessEntittyID NOT null;
Question: Who are the employees that submitted resume to Human Resource Department and got hired? State the last name.
SQL: SELECT person.lastname FROM employee INNER JOIN jobcandidate ON employee.businessentityid = jobcandidate.businessentityid INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE employee.businessentityid IN (212, 274)
Database: works_cycles
Note: female refers to gender = 'F'; single refers to maritalstatus = 'S';
Question: List down the email address of female single employees.
SQL: SELECT emailaddress.emailaddress FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid INNER JOIN emailaddress ON person.businessentityid = emailaddress.businessentityid WHERE employee.gender = 'F' AND employee.maritalstatus = 'S'
Database: works_cycles
Question: What are the color of products that were reviewed?
SQL: SELECT product.color FROM product INNER JOIN productreview ON product.productid = productreview.productid WHERE product.productid = 709 OR 937 OR 798
Database: works_cycles
Note: projected sales quota refers to salesquota; projected sales quota in 2013 refers to year(quotadate) = 2013; projected sales quota for 2013 = SUM(salesquota where year(quotadate) = 2013);
Question: What is the projected sales quota amount in 2013 and sales YTD amount for sales person with business entity ID 275?
SQL: SELECT sum(salesperson.salesquota) FROM salesperson INNER JOIN salespersonquotahistory ON salesperson.businessentityid = salespersonquotahistory.businessentityid WHERE salesperson.businessentityid = 275 AND strftime('%Y', quotadate) = '2013'
Database: works_cycles
Note: projected yearly sales quota refers to salesquota; sales quota in 2013 refers to year(quotadate) = 2013; person who did not achieve projected yearly sales quota refers to salesquota>salesytd;
Question: Provide the business entity ID who did not achieved projected yearly sales quota in 2013.
SQL: SELECT DISTINCT salesperson.businessentityid FROM salesperson INNER JOIN salespersonquotahistory ON salesperson.businessentityid = salespersonquotahistory.businessentityid WHERE strftime('%Y', salespersonquotahistory.quotadate) = '2013' AND salesperson.salesquota < salesperson.saleslastyear
Database: works_cycles
Note: female refers to gender = 'F'; employee who wish to receive email promotion refers to emailpromotion = 1; percentage = DIVIDE(SUM(gender = 'F')), (sum(gender = 'F' or gender = 'M'))) as percentage;
Question: Among the employees who wish to receive e-mail promotion from AdventureWorks, how many percent of them are female?
SQL: SELECT cast(sum(CASE WHEN employee.gender = 'F' THEN 1 ELSE 0 END) AS REAL) * 100 / count(employee.businessentityid) FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE person.emailpromotion = 1
Database: works_cycles
Note: non-sales employee refers to persontype = 'EM'; married refers to maritalstatus = 'M'; single refers to maritalstatus = 'S'; percentage = DIVIDE(SUM(maritalstatus = 'M'), (SUM(maritalstatus = 'S') as percentage;
Question: How many times is married non sales employees against single non-sales employees?
SQL: SELECT cast(sum(CASE WHEN employee.maritalstatus = 'M' THEN 1 ELSE 0 END) AS REAL) * 100 / sum(CASE WHEN employee.maritalstatus = 'S' THEN 1 ELSE 0 END) FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE person.persontype = 'EM'
Database: works_cycles
Note: projected yearly sales quota refers to salesquota; projected yearly sales quota in 2013 refers to year(quotadate) = 2013; percentage = (MULTIPLY(DIVIDE(SUM(bonus)), (SUM(salesquota))) as percentage;
Question: How much is the total bonus received by sales person and what is the percentage of it against the projected yearly sales quota in 2013?
SQL: SELECT sum(salesperson.bonus) , cast(sum(salesperson.bonus) AS REAL) * 100 / sum(salesperson.salesquota) FROM salesperson INNER JOIN salespersonquotahistory ON salesperson.businessentityid = salespersonquotahistory.businessentityid WHERE strftime('%Y', salespersonquotahistory.quotadate) = '2013'
Database: works_cycles
Note: type of credit card refers to cardtype; cardtype = 'Vista';
Question: How many types of credit cards are there and how many are vista?
SQL: SELECT count(cardnumber) FROM creditcard WHERE cardtype = 'vista'
Database: works_cycles
Question: What is the name of the product with the id "475"?
SQL: SELECT name FROM product WHERE productid = 475
Database: works_cycles
Note: birthdate<'1980-01-01'; single refers to maritalstatus = 'S' or null;
Question: Among the employees born before 1980 , how many of them are single?
SQL: SELECT count(businessentityid) FROM employee WHERE maritalstatus = 's' AND birthdate < '1980-1-1'
Database: works_cycles
Question: List all the names of the stores assigned to the sales person with the id "277".
SQL: SELECT name FROM store WHERE salespersonid = 277
Database: works_cycles
Note: transactiondate BETWEEN '2013-08-01' AND '2013-08-30'; sold in refers to transactiontype = 'S' which means SalesOrder;
Question: How many products with the id "989" were sold in August 2013?
SQL: SELECT sum(quantity) FROM transactionhistory WHERE transactiondate LIKE '2013-08%' AND transactiontype = 'S' AND productid = 989
Database: works_cycles
Note: card that expires in 2007 refers to expyear = 2007;
Question: List all of the credit cards that had expired by 2007.
SQL: SELECT cardnumber FROM creditcard WHERE expyear < 2007
Database: works_cycles
Note: pay rate refers to rate; 20 years old at the time of being hired refers to SUBTRACT(year(hiredate)), (year(birthdate))) = 20;
Question: List all the pay rates of all employees that were hired at 20 years of age.
SQL: SELECT employeepayhistory.rate FROM employee INNER JOIN employeepayhistory ON employee.businessentityid = employeepayhistory.businessentityid WHERE strftime('%Y', employee.hiredate) - strftime('%Y', employee.birthdate) = 20
Database: works_cycles
Note: business id refers to businessentityid;
Question: What is the name of the territory assigned to the sales person with business id "277"?
SQL: SELECT salesterritory.name FROM salesperson INNER JOIN salesterritory ON salesperson.territoryid = salesterritory.territoryid WHERE salesperson.businessentityid = 277
Database: works_cycles
Note: full name = firstname+middlename+lastname; Vice President of production is a jobtitle;
Question: What is the full name of the Vice President of Production?
SQL: SELECT person.firstname, person.middlename, person.lastname FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE employee.jobtitle = 'Vice President of Production'
Database: works_cycles
Note: Information Service is a name of department;
Question: How many employees in the Information Service department work the evening shift?
SQL: SELECT count(employeedepartmenthistory.businessentityid) FROM department INNER JOIN employeedepartmenthistory ON department.departmentid = employeedepartmenthistory.departmentid INNER JOIN shift ON employeedepartmenthistory.shiftid = shift.shiftid WHERE department.name = 'Information Services' AND shift.name = 'Evening'
Database: works_cycles
Note: below average rating refers to creditrating = 5;
Question: List all the purchase order ids of the vendor with a below average rating.
SQL: SELECT purchaseorderheader.purchaseorderid FROM vendor INNER JOIN purchaseorderheader ON vendor.businessentityid = purchaseorderheader.vendorid WHERE vendor.creditrating = 5
Database: works_cycles
Question: Is the phone number "114-555-0100" a work number or a home number?
SQL: SELECT phonenumbertype.name FROM personphone INNER JOIN phonenumbertype ON personphone.phonenumbertypeid = phonenumbertype.phonenumbertypeid WHERE personphone.phonenumber = '114-555-0100'
Database: works_cycles
Note: Catgo Transport 5 is a name of shipping method; orderdate = '2011-12-14'; total shipment cost = SUM(freight);
Question: What is the total shipment by "cargo transport 5" cost of all purchase orders created on 12/14/2011?
SQL: SELECT sum(purchaseorderheader.freight) FROM shipmethod INNER JOIN purchaseorderheader ON shipmethod.shipmethodid = purchaseorderheader.shipmethodid WHERE shipmethod.name = 'cargo transport 5' AND purchaseorderheader.orderdate = '2011-12-14'
Database: works_cycles
Note: SP is an abbreviation for Sales person; persontype = 'SP';
Question: How many sales orders did the salesperson David R. Campbell create?
SQL: SELECT count(salesorderheader.totaldue) FROM person INNER JOIN salesorderheader ON person.modifieddate = salesorderheader.duedate WHERE person.firstname = 'David' AND person.middlename = 'R' AND person.lastname = 'Campbell' AND person.persontype = 'SP'
Database: works_cycles
Note: Facilities Manager is a job title;
Question: What is the email address of the Facilities Manager?
SQL: SELECT emailaddress.emailaddress FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid INNER JOIN emailaddress ON person.businessentityid = emailaddress.businessentityid WHERE employee.jobtitle = 'Facilities Manager'
Database: works_cycles
Note: Canada is name of sales territory;
Question: How many customers are there in Canada?
SQL: SELECT count(customer.customerid) FROM salesterritory INNER JOIN customer ON salesterritory.territoryid = customer.territoryid WHERE salesterritory.name = 'Canada'
Database: works_cycles
Note: shipping address = addressline1+addressline2+city;
Question: What is the shipping address for the sales order "43873"?
SQL: SELECT salesorderheader.shiptoaddressid FROM salesorderheader INNER JOIN address ON salesorderheader.billtoaddressid = address.addressid WHERE salesorderheader.salesorderid = 43873 GROUP BY salesorderheader.shiptoaddressid
Database: works_cycles
Note: sickleavehours>65;
Question: List the first names of the people with more than 65 sick leave hours.
SQL: SELECT person.firstname FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE employee.sickleavehours > 65
Database: works_cycles
Note: production technician is a job title; below average rate refers to rate<AVG(rate);
Question: Among all the production technicians, how many have a below average pay rate for a production technician?
SQL: SELECT count(employee.businessentityid) FROM employee INNER JOIN employeepayhistory ON employee.businessentityid = employeepayhistory.businessentityid WHERE employee.jobtitle LIKE 'Production Technician%' AND employeepayhistory.rate < ( SELECT avg(employeepayhistory.rate) FROM employee INNER JOIN employeepayhistory ON employee.businessentityid = employeepayhistory.businessentityid WHERE employee.jobtitle LIKE 'Production Technician%' )
Database: works_cycles
Note: proportion = DIVIDE(SUM(name = 'UK')), (COUNT(salesorderid))) as count;
Question: What proportion of sales orders are made from the United Kingdom?
SQL: SELECT cast(sum(CASE WHEN salesterritory.name = 'United Kingdom' THEN 1 ELSE 0 END) AS REAL) * 100 / count(salesorderheader.salesorderid) FROM salesorderheader INNER JOIN salesterritory ON salesorderheader.territoryid = salesterritory.territoryid
Database: works_cycles
Question: When is the modified date of the phone number "1500 555-0143"?
SQL: SELECT modifieddate FROM personphone WHERE phonenumber = '1 (11) 500 555-0143'
Database: works_cycles
Note: business ID refers to businessentityid; sales total year to date refers to salesytd; most sales total year to date refers to MAX(salesytd);
Question: What is the business ID of the person who has made the most sales total year to date?
SQL: SELECT businessentityid FROM salesperson ORDER BY salesytd DESC LIMIT 1
Database: works_cycles
Note: active vendors refers to activeflag = 1; vendor who offer a purchasing web service refers to purchasingwebserviceurl NOT null;
Question: List all active vendors who offer a purchasing web service.
SQL: SELECT name FROM vendor WHERE activeflag = 1
Database: works_cycles
Note: modifieddate between'2014-09-12 00:00:00' and '2014-09-12 23:59:59';
Question: Which territory has the most customers as of 9/12/2014?
SQL: SELECT territoryid FROM customer WHERE modifieddate < '2014-12-09' GROUP BY territoryid ORDER BY count(territoryid) DESC LIMIT 1
Database: works_cycles
Note: total cost = SUM(totaldue); orderdate = '2013-05-29';
Question: What is the total cost for all the orders placed on 5/29/2013?
SQL: SELECT sum(totaldue) FROM purchaseorderheader WHERE orderdate LIKE '2013-05-29%'
Database: works_cycles
Note: vendor contact refers to persontype = 'VC';
Question: What is the most common first name among the vendor contact?
SQL: SELECT firstname FROM person WHERE persontype = 'VC' GROUP BY firstname ORDER BY count(*) DESC LIMIT 1
Database: works_cycles
Note: full name = firstname+middlename+lastname; production Technician - WC50 is a job title;
Question: List the full name of all the 'Production Technician - WC50'
SQL: SELECT person.firstname, person.middlename, person.lastname FROM employee INNER JOIN person USING (businessentityid) WHERE employee.jobtitle = 'Production Technician - WC50' GROUP BY person.firstname, person.middlename, person.lastname