Chinastark/bird_dataset huggingface dataset:
Database: works_cycles
Note: documents pending approval refers to status = 1;
Question: Please list the titles of the documents that are pending approval.
SQL: SELECT title FROM document WHERE status = 1
Database: works_cycles
Note: document has been approved refers to status = 2;
Question: Please list the job titles of the employees who has a document that has been approved.
SQL: SELECT DISTINCT employee.businessentityid, employee.jobtitle FROM document INNER JOIN employee ON document.owner = employee.businessentityid WHERE document.status = 2
Database: works_cycles
Note: oldest employee refers to min(birthdate); payfrequency = 1 refers to ‘Salary received monthly’; payfrequency = 2 refers to ‘Salary received biweekly';
Question: What is the pay frequency of the oldest employee?
SQL: SELECT employeepayhistory.payfrequency FROM employeepayhistory INNER JOIN employee ON employeepayhistory.businessentityid = employee.businessentityid ORDER BY employee.birthdate ASC LIMIT 1
Database: works_cycles
Note: married refers to maritalstatus = M; highest pay frequency refers to payfrequency = 2;
Question: Among the employees whose pay frequencies are the highest, how many of them are married?
SQL: SELECT count(employeepayhistory.businessentityid) FROM employeepayhistory INNER JOIN employee ON employeepayhistory.businessentityid = employee.businessentityid WHERE employee.maritalstatus = 'M' AND employeepayhistory.payfrequency = ( SELECT payfrequency FROM employeepayhistory ORDER BY payfrequency DESC LIMIT 1 )
Database: works_cycles
Note: hired the latest refers to max(hiredate);
Question: For the employee who has been hired the latest, what is his or her pay rate?
SQL: SELECT employeepayhistory.rate FROM employeepayhistory INNER JOIN employee ON employeepayhistory.businessentityid = employee.businessentityid ORDER BY employee.hiredate DESC LIMIT 1
Database: works_cycles
Note: pay rate above 40 refers to rate>40; male employee refers to gender = M;
Question: Among the employees who have a pay rate of above 40, how many of them are male?
SQL: SELECT sum(CASE WHEN employee.gender = 'M' THEN 1 ELSE 0 END) FROM employeepayhistory INNER JOIN employee ON employeepayhistory.businessentityid = employee.businessentityid WHERE employeepayhistory.rate > 40
Database: works_cycles
Note: employee exempt from collective bargaining refers to salariedflag = 1; highest pay rate refers to max(rate);
Question: What is the highest pay rate of the employees who are exempt from collective bargaining?
SQL: SELECT employeepayhistory.rate FROM employeepayhistory INNER JOIN employee ON employeepayhistory.businessentityid = employee.businessentityid WHERE employee.salariedflag = 1 ORDER BY employeepayhistory.rate DESC LIMIT 1
Database: works_cycles
Note: highest pay frequency refers to payfrequency = 2;
Question: For the employees who have the highest pay frequency, please list their vacation hours.
SQL: SELECT employee.vacationhours FROM employeepayhistory INNER JOIN employee ON employeepayhistory.businessentityid = employee.businessentityid WHERE employee.businessentityid = ( SELECT businessentityid FROM employeepayhistory ORDER BY rate DESC LIMIT 1 )
Database: works_cycles
Note: longest vacation hour refers to max(vacationhours);
Question: What is the pay rate of the employee who has the longest vacation hours?
SQL: SELECT employeepayhistory.rate FROM employeepayhistory INNER JOIN employee ON employeepayhistory.businessentityid = employee.businessentityid ORDER BY employee.vacationhours DESC LIMIT 1
Database: works_cycles
Note: more than 10 sick leave hours refers to sickleavehours>10; pay rate over 35 refers to rate>35;
Question: How many employees with a pay rate of over 35 have more than 10 sick leave hours?
SQL: SELECT count(employeepayhistory.businessentityid) FROM employeepayhistory INNER JOIN employee ON employeepayhistory.businessentityid = employee.businessentityid WHERE employee.sickleavehours > 10 AND employeepayhistory.rate > 35
Database: works_cycles
Note: active status of employees refers to currentflag = 1; Male refers to gender = 'M'; highest frequency refers to payfrequency = 2;
Question: Among the active male employees, how many of them are paid with the highest frequency?
SQL: SELECT count(employeepayhistory.businessentityid) FROM employeepayhistory INNER JOIN employee ON employeepayhistory.businessentityid = employee.businessentityid WHERE employee.currentflag = 1 AND employee.gender = 'M' AND employeepayhistory.payfrequency = 2
Database: works_cycles
Note: Sales person refers to persontype = 'SP'; Male refers to gender = 'M';
Question: How many male employees have the job position of sales person?
SQL: SELECT count(employee.businessentityid) FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE employee.gender = 'M' AND person.persontype = 'SP'
Database: works_cycles
Note: Oldest employee refers to Max ( Subtract((now())-birthdate));
Question: What is the job position of the oldest employee?
SQL: SELECT person.persontype FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid ORDER BY employee.birthdate ASC LIMIT 1
Database: works_cycles
Note: lowest pay rate refers to Min(rate);
Question: What is the name style of the employee with the lowest pay rate?
SQL: SELECT person.namestyle FROM employeepayhistory INNER JOIN person ON employeepayhistory.businessentityid = person.businessentityid WHERE employeepayhistory.rate IS NOT NULL ORDER BY employeepayhistory.rate ASC LIMIT 1
Database: works_cycles
Note: married refers to maritalstatus = 'M'; western name style refers to namestyle = '0';
Question: Among the employees who are married, how many of them have a western name style?
SQL: SELECT count(employee.businessentityid) FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE person.namestyle = 0 AND employee.maritalstatus = 'M'
Database: works_cycles
Note: Contact does wish to receive e-mail promotions refers to emailpromotion = (1,2); more than 10 hours of sick leave refer to sickleavehours >10;
Question: Among the employees who have more than 10 hours of sick leave, how many of them wish to receive e-mail promotions?
SQL: SELECT count(employee.businessentityid) FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE person.emailpromotion = 1 AND employee.sickleavehours > 10
Database: works_cycles
Note: Contact does wish to receive e-mail promotions refers to emailpromotion = (1,2); more than 20 vacations hours refers to vacationhours>20;
Question: Please list the employees who have more than 20 vacations hours and wish to receive e-mail promotions.
SQL: SELECT employee.businessentityid FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE person.emailpromotion = 1 AND employee.vacationhours > 20
Database: works_cycles
Note: Sales person refers to persontype = 'SP'; oldest employee refers to Max (Subtract((now())-birthdate));
Question: Please give the additional contact information of the oldest employee with the jod position of sales person.
SQL: SELECT person.additionalcontactinfo FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE persontype = 'SP' ORDER BY employee.birthdate ASC LIMIT 1
Database: works_cycles
Note: western name style refers to namestyle = 0; Male refers to gender = 'M';
Question: What is the first name of the male employee who has a western name style?
SQL: SELECT person.firstname FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE person.namestyle = 0 AND employee.gender = 'M'
Database: works_cycles
Note: active status of employees refers to currentflag = 1;
Question: Among the active employees, how many of them have a courtesy title of "Mr"?
SQL: SELECT count(employee.businessentityid) FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE employee.currentflag = 1 AND person.title = 'Mr.'
Database: works_cycles
Note: married refers to maritalstatus = 'M'; Highest pay rate refers to Max(rate);
Question: Please give the personal information of the married employee who has the highest pay rate.
SQL: SELECT person.demographics FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid INNER JOIN employeepayhistory ON person.businessentityid = employeepayhistory.businessentityid WHERE employee.maritalstatus = 'M' ORDER BY employeepayhistory.rate DESC LIMIT 1
Database: works_cycles
Note: store contact refers to persontype = 'SC';
Question: What is the surname suffix of the employee who works as a store contact and has the longest sick leave hours?
SQL: SELECT person.suffix FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE person.persontype = 'SP' ORDER BY employee.sickleavehours DESC LIMIT 1
Database: works_cycles
Note: married refers to maritalstatus = 'M'; Eastern name style refers to namestyle = 1;
Question: Among the married employees with the highest pay frequency, how many of them have an eastern name style?
SQL: SELECT count(employee.businessentityid) FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid INNER JOIN employeepayhistory ON person.businessentityid = employeepayhistory.businessentityid WHERE employee.maritalstatus = 'M' AND person.namestyle = 1 AND employeepayhistory.rate = ( SELECT rate FROM employeepayhistory ORDER BY rate DESC LIMIT 1 )
Database: works_cycles
Note: active status of employees refers to currentflag = 1; the employee does not wish to receive an e-mail promotion refers to emailpromotion = 0;
Question: How many active employees do not wish to receive e-mail promotions?
SQL: SELECT count(employee.businessentityid) FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE employee.currentflag = 1 AND person.emailpromotion = 1
Database: works_cycles
Note: store contact refers to persontype = 'SC';
Question: Please list the credit card IDs of the employees who work as store contact.
SQL: SELECT personcreditcard.creditcardid FROM person INNER JOIN personcreditcard ON person.businessentityid = personcreditcard.businessentityid WHERE person.persontype = 'SC'
Database: works_cycles
Note: employee refers to persontype = 'EM'; Male refers to gender = 'M'; Average = Divide( SUM(vacationhours(persontype = 'EM'& gender = 'M')),Count(businessentityid(persontype = 'EM' & gender = 'M')));
Question: How many vacation hours do the male employees have on average?
SQL: SELECT cast(sum(employee.vacationhours) AS REAL) / count(employee.businessentityid) FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE employee.gender = 'M' AND person.persontype = 'EM'
Database: works_cycles
Note: married refers to maritalstatus = 'M'; Contact does wish to receive e-mail promotions from Adventure Works refers to emailpromotion = 1; Average = Divide (Sum(rate (maritalstatus = 'M' & emailpromotion = 1))), Count (businessentityid (maritalstatus = 'M' & emailpromotion = 1)); MAX(rate (maritalstatus = 'M' & emailpromotion = 1) - Average;
Question: Among the employees who are married and wish to receive e-mail promotions, how much higher is their highest pay rate from the average pay rate?
SQL: SELECT max(employeepayhistory.rate) - sum(employeepayhistory.rate) / count(employeepayhistory.businessentityid) FROM employeepayhistory INNER JOIN person ON employeepayhistory.businessentityid = person.businessentityid INNER JOIN employee ON person.businessentityid = employee.businessentityid WHERE person.emailpromotion = 2 AND employee.maritalstatus = 'M'
Database: works_cycles
Note: married refers to maritalstatus = 'M'; western name style refers to namestyle = 0; store contact refers to persontype = 'SC'; probability = Divide (Count (businessentityid( persontype = 'SC' & maritalstatus = 'M')), Count (businessentityid ( persontype) & Mariatlstatus = 'M'));
Question: If a married employee has a western name style, what is the probability of him or her working as a store contact?
SQL: SELECT cast(count(iif(person.persontype = 'SC', person.persontype, NULL)) AS REAL) / count(person.persontype) FROM person INNER JOIN employee WHERE person.persontype = 'SC' AND person.namestyle = 0 AND employee.maritalstatus = 'M'
Database: works_cycles
Note: currentflag = 1 refers to the active status of employees; Percentage = Divide (Count (businessentityid (currentflag = 1 & vacationhours >20 & sickleavehours > 10)), Count (businessentityid (currentflag = 1 & sickleavehours>10))) * 100;
Question: Among the active employees with over 10 hours of sick leave, what is the percentage of the employees with over 20 vacation hours?
SQL: SELECT cast(sum(CASE WHEN employee.vacationhours > 20 THEN 1 ELSE 0 END) AS REAL) * 100 / count(employeepayhistory.businessentityid) FROM employeepayhistory INNER JOIN employee ON employeepayhistory.businessentityid = employee.businessentityid WHERE employee.currentflag = 1 AND employee.sickleavehours > 10
Database: works_cycles
Note: average = DIVIDE(SUM(lastreceiptcost), COUNT(onorderqty)) where averageleadtime = 60;
Question: Average of the last receipt cost of the products whose average lead time is 60 days.
SQL: SELECT sum(lastreceiptcost) / count(productid) FROM productvendor WHERE averageleadtime = 60
Database: works_cycles
Note: purchase orders refers to transactiontype = 'P'; first six months of 2012 refers to transactiondate bewteen '2012-01-01'and '2012-06-30'; average = DIVIDE(actualcost where transactiontype = 'P', count(transactionid));
Question: Average cost of purchase orders made during the first six months of 2012.
SQL: SELECT cast(sum(actualcost) AS REAL) / count(transactionid) FROM transactionhistoryarchive WHERE transactiontype = 'P' AND transactiondate >= '2012-01-01' AND transactiondate < '2012-07-01'
Database: works_cycles
Note: male refers to gender = 'M'; hired throughout the years 2009 refers to Year(hiredate) = 2009; married refers to maritalstatus = 'M'; percentage = DIVIDE(count(businessentityid(gender = 'M'& Year(hiredate) = '2009& maritalstatus = 'M')), count(businessentityid(gender = 'M'& Year(hiredate) = 2009)));
Question: What percentage of male employees hired throughout the years 2009 are married?
SQL: SELECT cast(sum(CASE WHEN maritalstatus = 'M' THEN 1 ELSE 0 END) AS REAL) * 100 / count(businessentityid) FROM employee WHERE substr(hiredate, 1, 4) = '2009' AND gender = 'M'
Database: works_cycles
Note: wants Receive Email promotions of AdventureWorks and selected partners refers to emailpromotion = 2; store contact refers to persontype = 'SC'; percentage = DIVIDE(count(businessentityid(firstname = 'Marry'&emailpromotion = '2')),count(businessentityid)));
Question: What percentage of people named Mary who wants Receive Email promotions of AdventureWorks and selected partners are store contacts?
SQL: SELECT cast(sum(CASE WHEN emailpromotion = 2 THEN 1 ELSE 0 END) AS REAL) * 100 / sum(CASE WHEN persontype = 'SC' THEN 1 ELSE 0 END) FROM person WHERE firstname = 'Mary'
Database: works_cycles
Note: Profit = SUBTRACT(standardprice, LastRecipeCost);
Question: List, by ProductID, all products whose profit, relative to the standard price, is negative.
SQL: SELECT DISTINCT productid FROM productvendor WHERE standardprice - lastreceiptcost < 0
Database: works_cycles
Note: approved refers to status = 2 , average total due price = AVG( DIVIDE(totaldue, SUM(status = 2 )));
Question: What is the average total due price of products with approved status?
SQL: SELECT sum(totaldue) / count(totaldue) FROM purchaseorderheader WHERE status = 2
Database: works_cycles
Note: quantities not greater than 3 refers to orderqty<3; discount of 0.2 refers to unitpricediscount = 0.2; percentage = DIVIDE(count(salesorderid(orderqty<3 & unitpricediscount = 0.2)), count(salesorderid))*100%;
Question: What is the percentage, by number of sales order units, for orders with quantities not greater than 3 and a discount of 0.2?
SQL: SELECT cast(sum(CASE WHEN orderqty < 3 AND unitpricediscount = 0.2 THEN 1 ELSE 0 END) AS REAL) / count(salesorderid) FROM salesorderdetail
Database: works_cycles
Note: increased their current year sales by more than 60% refers to DIVIDE(SUBTRACT(salesytd, saleslastyear),saleslastyear)>0.6;
Question: Lists all companies by BusinessEntityID that increased their current year sales by more than 60% over last year's sales and have a bonus greater than 3,000.
SQL: SELECT businessentityid FROM salesperson WHERE salesytd > saleslastyear + saleslastyear * 0.6 AND bonus > 3000
Database: works_cycles
Note: their home address as their address refers to addresstypeid = 2; address corresponds to the shipping address refers to addresstypeid = 5;
Question: Add the number of businesses that indicate their home address as their address and those whose address corresponds to the shipping address.
SQL: SELECT sum(CASE WHEN addresstype.name = 'Home' THEN 1 ELSE 0 END) , sum(CASE WHEN addresstype.name = 'Shipping' THEN 1 ELSE 0 END) FROM businessentityaddress INNER JOIN addresstype ON businessentityaddress.addresstypeid = addresstype.addresstypeid
Database: works_cycles
Note: sales order for 32 units refers to orderqty = 32;
Question: Identifies the ID number of the customer whose sales order for 32 units had a unit price of 35.
SQL: SELECT customer.customerid FROM salesorderdetail INNER JOIN customer WHERE salesorderdetail.unitprice = 35 AND salesorderdetail.orderqty = 32
Database: works_cycles
Note: Colonial Voice card refers to cardtype = 'ColonialVoice' ; expired in March 2005 refers to expmonth = 3, expyear = 2005;
Question: What company has a Colonial Voice card that expired in March 2005?
SQL: SELECT personcreditcard.businessentityid FROM creditcard INNER JOIN personcreditcard ON creditcard.creditcardid = personcreditcard.creditcardid WHERE creditcard.cardtype = 'ColonialVoice' AND creditcard.expmonth = 3 AND creditcard.expyear = 2005
Database: works_cycles
Note: last receipt date is August 17, 2011 refers to lastreceiptdate>= '2011-08-17 00:00:00' and lastreceiptdate < '2011-08-18 00:00:00';
Question: What is the credit rating of the company whose average lead time is 16 days for a standard price of 18.9900 and whose last receipt date is August 27, 2011?
SQL: SELECT vendor.creditrating FROM productvendor INNER JOIN vendor ON productvendor.businessentityid = vendor.businessentityid WHERE productvendor.standardprice = 18.9900 AND productvendor.averageleadtime = 16 AND strftime('%Y-%m-%d', productvendor.lastreceiptdate) = '2011-08-27'
Database: works_cycles
Question: Calculate the number of products if we add the products of the accessories and components categories.
SQL: SELECT count(productid) FROM product WHERE name LIKE '%accessories %' OR name LIKE '%components%'
Database: works_cycles
Note: newest employee refers to MAX(startdate);
Question: What is the job title of the newest employee in department 12?
SQL: SELECT employee.jobtitle FROM employee INNER JOIN employeedepartmenthistory ON employee.businessentityid = employeedepartmenthistory.businessentityid WHERE employeedepartmenthistory.departmentid = 12 ORDER BY employeedepartmenthistory.startdate DESC LIMIT 1
Database: works_cycles
Note: unmarried refers to maritalstatus = 'S', male refers to gender = 'M', production Supervisors is a job title;
Question: List the first and last name of all unmarried male Production Supervisors.
SQL: SELECT person.firstname, person.lastname FROM employee INNER JOIN person ON employee.businessentityid = person.businessentityid WHERE employee.maritalstatus = 'S' AND employee.gender = 'M' AND employee.jobtitle LIKE 'Production Supervisor%'
Database: works_cycles
Note: located in the Subassembly category refers to name = 'Subassembly';
Question: How many products are there if we add all those located in the Subassembly category?
SQL: SELECT count(LOCATION.locationid) FROM LOCATION INNER JOIN productinventory USING (locationid) WHERE LOCATION.name = 'Subassembly'
Database: works_cycles
Note: number of product rejected refers to ScrapedQty; trim length that is too long refers to scrap reason where name = 'Trim length too long';
Question: Sum the total number of products rejected for having a trim length that is too long.
SQL: SELECT sum(workorder.scrappedqty) FROM scrapreason INNER JOIN workorder ON scrapreason.scrapreasonid = workorder.scrapreasonid WHERE scrapreason.name = 'Trim length too long'
Database: works_cycles
Note: employee number 257 refers to employeeid = 257; pending shipment status refers to status = 3;
Question: Calculate the total quantity of purchased product that has been prepared by employee number 257 and is in pending shipment status.
SQL: SELECT sum(purchaseorderdetail.orderqty) FROM purchaseorderheader INNER JOIN purchaseorderdetail ON purchaseorderheader.purchaseorderid = purchaseorderdetail.purchaseorderid WHERE purchaseorderheader.status = 1
Database: works_cycles
Note: do not have any type of offer refers to description = 'No Discount'; sold in an amount greater than 2 refers to orderqty>2;
Question: If we discount the products that do not have any type of offer, how many different products have been sold in an amount greater than 2 units per order?
SQL: SELECT count(DISTINCT salesorderdetail.productid) FROM salesorderdetail INNER JOIN specialofferproduct ON salesorderdetail.specialofferid = specialofferproduct.specialofferid INNER JOIN specialoffer ON specialofferproduct.specialofferid = specialoffer.specialofferid WHERE salesorderdetail.orderqty > 2 AND salesorderdetail.unitpricediscount = 0
Database: works_cycles
Note: yellow product refers to color = 'Yellow'; minimum inventory stock of 500 units refers to safetystocklevel = 500;
Question: What type of transaction was made with the only yellow product, size 62 and with a minimum inventory stock of 500 units?
SQL: SELECT DISTINCT transactionhistory.transactiontype FROM product INNER JOIN transactionhistory ON product.productid = transactionhistory.productid WHERE product.size = 62 AND product.color = 'Yellow' AND product.safetystocklevel = 500
Database: works_cycles
Note: gray is color of product;
Question: What is the name of the subcategory to which the gray product with the lowest safety stock level belongs?
SQL: SELECT productsubcategory.name FROM productsubcategory INNER JOIN product USING (productsubcategoryid) WHERE product.color = 'Grey' GROUP BY productsubcategory.name
Database: works_cycles
Note: in grams refers to weightunitmeasurecode = 'G';
Question: What is the product cost end date with the highest weight in grams?
SQL: SELECT productcosthistory.enddate FROM product INNER JOIN productcosthistory ON product.productid = productcosthistory.productid WHERE product.weightunitmeasurecode = 'G' ORDER BY product.weight DESC LIMIT 1
Database: works_cycles
Note: rejected quantity refers to scrappedqty; rejected by Drill size refers to name in ('Drill size too small','Drill size too large'); percentage = DIVIDE(SUM(scrappedqty) where name in('Drill size too small','Drill size too large'), orderqty);
Question: What is the percentage of the total products ordered were not rejected by Drill size?
SQL: SELECT cast(sum(CASE WHEN employee.vacationhours > 20 THEN 1 ELSE 0 END) AS REAL) * 100 / count(employeepayhistory.businessentityid) FROM employeepayhistory INNER JOIN employee ON employeepayhistory.businessentityid = employee.businessentityid WHERE employee.currentflag = 1 AND employee.sickleavehours > 10
Database: works_cycles
Note: shipping method was Cargo Transport 5 refers to name = 'Cargo Transport 5'; average = DIVIDE(SUM(orderqty where name = 'Cargo Transport 5'), COUNT(shipmethodid));
Question: Calculate the average of the total ordered quantity of products purchased whose shipping method was Cargo Transport 5.
SQL: SELECT cast(sum(iif(shipmethod.shipmethodid = 5, purchaseorderdetail.orderqty, 0)) AS REAL) / count(purchaseorderdetail.productid) FROM shipmethod INNER JOIN purchaseorderheader ON shipmethod.shipmethodid = purchaseorderheader.shipmethodid INNER JOIN purchaseorderdetail ON purchaseorderheader.purchaseorderid = purchaseorderdetail.purchaseorderid