Chinastark/bird_dataset huggingface dataset:
Database: synthea
Note: white refers to race = 'white'; birth year is 1935 refers to substr(birthdate, 1, 4) = '1935'; stroke refers to conditions.description = 'Stroke';
Question: How many white patients whose birth year is 1935 have a stroke?
SQL: SELECT count(DISTINCT patients.patient) FROM patients INNER JOIN conditions ON patients.patient = conditions.patient WHERE strftime('%Y', patients.birthdate) = '1935' AND patients.race = 'white' AND conditions.description = 'Stroke'
Database: synthea
Note: IPV immunization refers to immunizations.description = 'IPV';
Question: Which conditions the patient has when receiving the IPV immunization?
SQL: SELECT DISTINCT conditions.description FROM patients INNER JOIN conditions ON patients.patient = conditions.patient INNER JOIN immunizations ON patients.patient = immunizations.patient WHERE immunizations.description = 'IPV'
Database: synthea
Note: patient ids refers to patients.patient; disease with the most occurrence refers to MAX(all_prevalences.OCCURENCES);
Question: List the patient ids whose disease has the most occurrences.
SQL: SELECT patients.patient FROM patients INNER JOIN conditions ON patients.patient = conditions.patient INNER JOIN all_prevalences ON all_prevalences.item = conditions.description ORDER BY all_prevalences.occurrences DESC LIMIT 1
Database: synthea
Note: full names = first, last; condition described as cystitis refers to conditions.description = ''Cystitis';
Question: List all the full names of patients with a condition described as cystitis.
SQL: SELECT DISTINCT patients.first, patients.last FROM patients INNER JOIN conditions ON patients.patient = conditions.patient WHERE conditions.description = 'Cystitis'
Database: synthea
Note: male refers to gender = 'M'; immune to quadrivalent HPV refers to immunizations.description = 'HPV quadrivalent';
Question: How many male patients have been described as immune to quadrivalent HPV?
SQL: SELECT count(DISTINCT patients.patient) FROM patients INNER JOIN immunizations ON patients.patient = immunizations.patient WHERE immunizations.description = 'HPV  quadrivalent' AND patients.gender = 'M'
Database: synthea
Note: start date of the care plan refers to careplans.start;
Question: Indicate the start date of patient Walter Bahringer's care plan.
SQL: SELECT DISTINCT careplans.start FROM patients INNER JOIN careplans ON patients.patient = careplans.patient WHERE patients.first = 'Walter' AND patients.last = 'Bahringer'
Database: synthea
Question: Describe the care plans of patient Major D'Amore's plan of care.
SQL: SELECT DISTINCT careplans.description FROM patients INNER JOIN careplans ON patients.patient = careplans.patient WHERE patients.first = 'Major' AND patients.last = 'D''Amore'
Database: synthea
Note: percentage = MULTIPLY(DIVidE(COUNT(patients.patient WHERE gender = 'M'), COUNT(patients.patient) WHERE conditions.description = 'Viral sinusitis (disorder))), 100); male patients refers to gender = 'M'; viral sinusitis condition refers to conditions.description = 'Viral sinusitis (disorder)';
Question: Calculate the percentage of male patients with viral sinusitis condition.
SQL: SELECT cast(sum(CASE WHEN patients.gender = 'M' THEN 1 ELSE 0 END) AS REAL) * 100 / count(patients.patient) FROM patients INNER JOIN conditions ON patients.patient = conditions.patient WHERE conditions.description = 'Viral sinusitis (disorder)'
Database: synthea
Note: Penicillin V Potassium 250 MG refers to medications.description = 'Penicillin V Potassium 250 MG'; percentage = MULTIPLY(DIVidE(patients.patient WHERE gender = 'F'), COUNT(patients.patient) WHERE medications.description = 'Penicillin V Potassium 250 MG'), 100) female refers to gender = 'F';
Question: Among the patients who have been using Penicillin V Potassium 250 MG, what percentage of patients are female?
SQL: SELECT cast(sum(CASE WHEN patients.gender = 'F' THEN 1 ELSE 0 END) AS REAL) * 100 / count(patients.patient) FROM patients INNER JOIN medications ON patients.patient = medications.patient WHERE medications.description = 'Penicillin V Potassium 250 MG'
Database: synthea
Note: white refers to race = 'white'; average body height = AVG(observations.value WHERE observations.description = 'Body Height'); body height refers to observations.description = 'Body Height';
Question: Among the white patients, what is the average body height of the patients?
SQL: SELECT avg(observations.value) FROM observations INNER JOIN patients ON observations.patient = patients.patient WHERE patients.race = 'white' AND observations.description = 'Body Height'
Database: synthea
Note: living at 179 Sydni Roads, Taunton, MA 02780 US refers to address = '179 Sydni Roads Taunton MA 02780 US';
Question: Indicate the care plan needed for the patient living at 179 Sydni Roads, Taunton, MA 02780 US.
SQL: SELECT careplans.description FROM careplans INNER JOIN patients ON careplans.patient = patients.patient WHERE patients.address = '179 Sydni Roads Taunton MA 02780 US'
Database: synthea
Note: allergen refers to allergies.description;
Question: Provide the allergen of the Dominican patient named Dirk Languish.
SQL: SELECT allergies.description FROM allergies INNER JOIN patients ON allergies.patient = patients.patient WHERE patients.first = 'Dirk' AND patients.last = 'Langosh' AND patients.ethnicity = 'dominican'
Database: synthea
Note: allergic to peanuts refers to allergies.description = 'Allergy to peanuts'; asthma refers to conditions.description = 'Asthma';
Question: How many patients who are allergic to peanuts have asthma?
SQL: SELECT count(DISTINCT patients.patient) FROM conditions INNER JOIN patients ON conditions.patient = patients.patient INNER JOIN allergies ON patients.patient = allergies.patient WHERE conditions.description = 'Asthma' AND allergies.description = 'Allergy to peanuts'
Database: synthea
Note: 44-year-old = DIVidE(SUBTRACT(julianday(conditions.start), julianday(patients.birthdate)), 365, 0) = 44;
Question: Who is the 44-year-old patient diagnosed with drug overdose?
SQL: SELECT patients.first, patients.last FROM conditions INNER JOIN patients ON conditions.patient = patients.patient WHERE conditions.description = 'Drug overdose' AND round((strftime('%J', patients.deathdate) - strftime('%J', patients.birthdate)) / 365) = 44
Database: synthea
Note: social security number refers to ssn; highest systolic blood pressure refers to MAX(observations.value WHERE observations.description = 'Systolic Blood Pressure');
Question: Provide the social security number of the patient with the highest systolic blood pressure.
SQL: SELECT patients.ssn FROM observations INNER JOIN patients ON observations.patient = patients.patient WHERE observations.description = 'Systolic Blood Pressure' ORDER BY observations.value DESC LIMIT 1
Database: synthea
Note: highest prevalence percentage refers to MAX(prevalence percentage);
Question: What is the care plan description of the prevalent disease with the highest prevalence percentage?
SQL: SELECT careplans.description FROM all_prevalences INNER JOIN conditions ON conditions.description = all_prevalences.item INNER JOIN encounters ON conditions.encounter = encounters.id INNER JOIN careplans ON careplans.encounter = encounters.id ORDER BY all_prevalences."PREVALENCE PERCENTAGE" DESC LIMIT 1
Database: synthea
Note: social security number refers to ssn; ssn = '999-15-3685';
Question: What is the care plan for the patient with social security number 999-15-3685?
SQL: SELECT DISTINCT careplans.description FROM careplans INNER JOIN patients ON careplans.patient = patients.patient WHERE patients.ssn = '999-15-3685'
Database: synthea
Note: average age = AVG(DIVidE(SUBTRACT(deathdate is null WHERE (julianday(substr(datetime('now'), 1, 10)))), julianday(patients.birthdate)), 365); male refers to gender = 'M'; hypertension refers to conditions.description = 'Hypertension';
Question: Calculate the average age of the male patients that have hypertension.
SQL: SELECT sum(CASE WHEN patients.deathdate IS NULL THEN round((strftime('%J', date('now')) - strftime('%J', patients.birthdate)) / 365) ELSE round((strftime('%J', patients.deathdate) - strftime('%J', patients.birthdate)) / 365) END) / count(patients.patient) FROM conditions INNER JOIN patients ON conditions.patient = patients.patient WHERE conditions.description = 'Hypertension' AND patients.gender = 'M'
Database: synthea
Note: patients name = first, last; streptococcal sore throat disorder refers to medications.reasondescription = 'Streptococcal sore throat (disorder)';
Question: List 5 patients' name that need medication due to streptococcal sore throat disorder.
SQL: SELECT DISTINCT patients.first, patients.last FROM medications INNER JOIN patients ON medications.patient = patients.patient WHERE medications.reasondescription = 'Streptococcal sore throat (disorder)' LIMIT 5
Database: synthea
Note: body weight of 61.97 kg refers to observations.description = 'Body Weight' AND observations.value = 61.97; observations.units = 'kg';
Question: Who is the patient with a body weight of 61.97 kg?
SQL: SELECT patients.first, patients.last FROM observations INNER JOIN patients ON observations.patient = patients.patient WHERE observations.description = 'Body Weight' AND observations.units = 'kg' AND observations.value = 61.97
Database: synthea
Note: male patients refers to gender = 'M'; Penicillin V Potassium 250 MG refers to medications.description = 'Penicillin V Potassium 250 MG';
Question: Among the male patients, list down 5 birth dates of patients taking the medication "Penicillin V Potassium 250 MG".
SQL: SELECT DISTINCT patients.birthdate FROM medications INNER JOIN patients ON medications.patient = patients.patient WHERE medications.description = 'Penicillin V Potassium 250 MG' AND patients.gender = 'M' LIMIT 5
Database: synthea
Note: full name = first, last; Irish refers to ethnicity = 'irish'; prevalent diseases that have an occurrence greater than the 96% of the average occurrences of all conditions = occurrences > (AVG(MULTIPLY(all_prevalences.occurrences, 0.96)));
Question: List down the full name of Irish patients diagnosed with the prevalent diseases that have an occurrence greater than the 96% of the average occurrences of all conditions.
SQL: SELECT DISTINCT patients.first, patients.last FROM conditions INNER JOIN patients ON conditions.patient = patients.patient INNER JOIN all_prevalences ON conditions.description = all_prevalences.item WHERE patients.ethnicity = 'irish' AND 100 * cast(all_prevalences.occurrences AS REAL) / ( SELECT avg(occurrences) FROM all_prevalences ) > 96
Database: synthea
Note: difference = SUBTRACT(patients.patient WHERE marital = 'M'), COUNT(patients.patient WHERE marital = 'S') WHERE conditions.description = 'Diabetes'); married patients refers to marital = 'M'; single patients refers to marital = 'S'; diabetes refers to conditions.description = 'Diabetes';
Question: What is the difference between the number of married patients and the number of single patients with diabetes?
SQL: SELECT sum(CASE WHEN patients.marital = 'M' THEN 1 ELSE 0 END) - sum(CASE WHEN patients.marital = 'S' THEN 1 ELSE 0 END) FROM conditions INNER JOIN patients ON conditions.patient = patients.patient WHERE conditions.description = 'Diabetes'
Database: car_retails
Question: List the country and how many customers are there.
SQL: SELECT country, count(customernumber) FROM customers GROUP BY country
Database: car_retails
Note: amount of order refers to quantityordered; most amount of orders refers to SUM(quantityordered); estimated earnings refers to expected profits; expected profits = SUBTRACT(msrp, buyprice);
Question: Which different vendor has the most amount of orders? Calculate the total estimated earnings.
SQL: SELECT DISTINCT products.productvendor, products.msrp - products.buyprice FROM products INNER JOIN orderdetails ON products.productcode = orderdetails.productcode GROUP BY products.productvendor, products.msrp, products.buyprice ORDER BY count(orderdetails.quantityordered) DESC LIMIT 1
Database: car_retails
Question: Who is the sales agent of the distinct customer who paid the highest amount in the year 2004?
SQL: SELECT DISTINCT employees.lastname, employees.firstname FROM payments INNER JOIN customers ON payments.customernumber = customers.customernumber INNER JOIN employees ON customers.salesrepemployeenumber = employees.employeenumber WHERE strftime('%Y', payments.paymentdate) = '2004' ORDER BY payments.amount DESC LIMIT 1
Database: car_retails
Note: Mini Gifts Distributors Ltd. Is the customer name; shippeddate between '2003-01-01' and '2003-12-31'; total price = MULTIPLY(quantityordered, priceeach);
Question: What was the total price of the products shipped to Rovelli Gifts Distributors Ltd. between 1/1/2003 and 12/31/2003?
SQL: SELECT orderdetails.priceeach * orderdetails.quantityordered FROM customers INNER JOIN orders ON customers.customernumber = orders.customernumber INNER JOIN orderdetails ON orders.ordernumber = orderdetails.ordernumber WHERE customers.customername = 'Rovelli Gifts' AND orders.status = 'Shipped' AND strftime('%Y', orders.shippeddate) = '2003'
Database: car_retails
Note: sales agent and sales representative are synonyms; Sydney is a city;
Question: How many employees are there in Sydney?
SQL: SELECT count(employeenumber) FROM employees WHERE officecode = ( SELECT officecode FROM offices WHERE city = 'Sydney' )
Database: car_retails
Note: reportsto' is the leader of the 'employeenumber';
Question: Which sales representatives in New York city whose leader is Anthony Bow with the employee number is 1143? Indicate their employee numbers.
SQL: SELECT employees.employeenumber FROM employees INNER JOIN offices ON employees.officecode = offices.officecode WHERE employees.reportsto = 1143 AND offices.city = 'NYC'
Database: car_retails
Note: paymentdate BETWEEN '2003-01-01' AND '2005-12-31'; average annual payments = DIVIDE(SUM(amount), 3);
Question: What is the average, highest and lowest annual payments collected between 1/1/2003 to 12/31/2005?
SQL: SELECT cast(sum(payments.amount) AS REAL) / 3, max(payments.amount) , min(payments.amount) FROM payments INNER JOIN customers ON payments.customernumber = customers.customernumber WHERE payments.paymentdate BETWEEN '2003-01-01' AND '2005-12-31'
Database: car_retails
Note: highest paying customer refers to MAX(amount); entire address = addressline1+addressline2;
Question: Which countries do the top 5 highest paying customers in a single payment come from? Indicate their entire address.
SQL: SELECT DISTINCT customers.country, customers.addressline1, customers.addressline2 FROM payments INNER JOIN customers ON payments.customernumber = customers.customernumber ORDER BY payments.amount DESC LIMIT 5
Database: car_retails
Note: Euro+ Shopping Channel is a customer name; year(paymentdate) = '2004';
Question: How many checks were issued by Euro+ Shopping Channel in the year 2004?
SQL: SELECT count(payments.checknumber) FROM payments INNER JOIN customers ON payments.customernumber = customers.customernumber WHERE customername = 'Euro+ Shopping Channel' AND strftime('%Y', payments.paymentdate) = '2004'
Database: car_retails
Note: classic car is a product line; most ordered product refers to MAX(quantityordered);
Question: Of all the classic cars, with a product scale of 1:18, which product is the most ordered product by customers?
SQL: SELECT products.productname FROM products INNER JOIN orderdetails ON products.productcode = orderdetails.productcode WHERE products.productscale = '1:18' AND products.productline = 'Classic Cars' GROUP BY products.productname ORDER BY sum(orderdetails.quantityordered) DESC LIMIT 1
Database: car_retails
Note: creditlimit <= 100000; total payment amount refers to amount; highest total payment amount refers to MAX(amount); year(paymentdate) = '2004';
Question: How many customers have a credit limit of not more than 100,000 and which customer made the highest total payment amount for the year 2004?
SQL: SELECT ( SELECT count(customernumber) FROM customers WHERE creditlimit <= 100000 AND customernumber IN ( SELECT customernumber FROM payments WHERE strftime('%Y', paymentdate) = '2004' ) ), customers.customername FROM customers INNER JOIN payments ON customers.customernumber = payments.customernumber WHERE customers.creditlimit <= 100000 AND strftime('%Y', payments.paymentdate) = '2004' GROUP BY customers.customernumber, customers.customername ORDER BY sum(payments.amount) DESC LIMIT 1
Database: car_retails
Note: Tokyo is a city; 'reportsto' is the leader of the 'employeenumber'; highest payment refers to MAX(amount); total amount of payments = SUM(amount);
Question: Which of the customers, whose Tokyo-based sales representative reports to the Vice President of Sales whose employee number is 1056, has paid the highest payment? List the customer's name, the contact person and calculate the total amount of that customer's total payments.
SQL: SELECT customers.customername, customers.contactfirstname, customers.contactlastname, sum(payments.amount) FROM employees INNER JOIN customers ON customers.salesrepemployeenumber = employees.employeenumber INNER JOIN payments ON customers.customernumber = payments.customernumber INNER JOIN offices ON employees.officecode = offices.officecode WHERE offices.city = 'Tokyo' AND employees.reportsto = 1056 GROUP BY customers.customername, customers.contactfirstname, customers.contactlastname ORDER BY amount DESC LIMIT 1
Database: car_retails
Note: expected profits = SUBTRACT(msrp, buyprice); total price = MULTIPLY(quantityordered, priceeach);
Question: Which two products has the highest and lowest expected profits? Determine the total price for each product in terms of the largest quantity that was ordered.
SQL: SELECT t2.productname, sum(orderdetails.quantityordered * orderdetails.priceeach) FROM orderdetails INNER JOIN ( SELECT productcode, productname FROM products ORDER BY msrp - buyprice DESC LIMIT 1 ) AS t2 ON orderdetails.productcode = t2.productcode UNION SELECT t2.productname, sum(quantityordered * priceeach) FROM orderdetails INNER JOIN ( SELECT productcode, productname FROM products ORDER BY msrp - buyprice ASC LIMIT 1 ) AS t2 ON orderdetails.productcode = t2.productcode
Database: car_retails
Note: total price = MULTIPLY(quantityordered, priceeach) > 4000; cancelled orders refer to status = 'Cancelled';
Question: How many different orders with a total price greater than 4000 are cancelled?
SQL: SELECT count(DISTINCT orderdetails.ordernumber) FROM orderdetails INNER JOIN orders ON orderdetails.ordernumber = orders.ordernumber WHERE orderdetails.quantityordered * orderdetails.priceeach > 4000 AND orders.status = 'Cancelled'
Database: car_retails
Note: year(orderdate) = '2003'; quantityordered < 30;
Question: How many distinct orders were there in 2003 when the quantity ordered was less than 30?
SQL: SELECT count(DISTINCT orderdetails.ordernumber) FROM orderdetails INNER JOIN orders ON orderdetails.ordernumber = orders.ordernumber WHERE orderdetails.quantityordered < 30 AND strftime('%Y', orders.orderdate) = '2003'
Database: car_retails
Note: total value = SUM(MULTIPLY(quantityordered, priceeach)); cancelled orders refers to status = 'Cancelled';
Question: What is the total value of cancelled orders?
SQL: SELECT sum(orderdetails.quantityordered * orderdetails.priceeach) FROM orderdetails INNER JOIN orders ON orderdetails.ordernumber = orders.ordernumber WHERE orders.status = 'Cancelled'
Database: car_retails
Note: Motorcycle is a product line; total value = SUM(MULTIPLY(quantityordered, priceeach));
Question: Please calculate the total value of Motorcycles orders.
SQL: SELECT sum(orderdetails.quantityordered * orderdetails.priceeach) FROM orderdetails INNER JOIN products ON orderdetails.productcode = products.productcode WHERE products.productline = 'Motorcycles'
Database: car_retails
Note: Planes is a product line;
Question: How many Planes orders were there?
SQL: SELECT count(orderdetails.productcode) FROM orderdetails INNER JOIN products ON orderdetails.productcode = products.productcode WHERE products.productline = 'Planes'
Database: car_retails
Note: expected profits greater than 100 = (SUBTRACT(msrp, buyprice))>100;
Question: How many orders which expected profits greater than 100?
SQL: SELECT count(orderdetails.productcode) FROM orderdetails INNER JOIN products ON orderdetails.productcode = products.productcode WHERE products.msrp - products.buyprice > 100
Database: car_retails
Note: average total price = DIVIDE(SUM(MULTIPLY(quantityordered, priceeach))), COUNT(ordernumber)); year(orderdate) = '2005';
Question: Please calculate the average total price of orders from Exoto Designs Vendor in 2005.
SQL: SELECT sum(orderdetails.quantityordered * orderdetails.priceeach) / count(orders.ordernumber) FROM products INNER JOIN orderdetails ON products.productcode = orderdetails.productcode INNER JOIN orders ON orderdetails.ordernumber = orders.ordernumber WHERE products.productvendor = 'Exoto Designs' AND strftime('%Y', orders.orderdate) = '2005'
Database: car_retails
Note: sales representative refers to jobtitle = 'Sales Rep';
Question: How many sales representatives who have office code is 1?
SQL: SELECT count(officecode) FROM employees WHERE jobtitle = 'Sales Rep' AND officecode = 1
Database: car_retails
Note: amount > 50000;
Question: Please list different customer names with the payment amount of over 50,000.
SQL: SELECT DISTINCT customers.customername FROM payments INNER JOIN customers ON payments.customernumber = customers.customernumber WHERE payments.amount > 50000
Database: car_retails
Note: USA is a country; total amount payment refers to SUM(amount);
Question: Please calculate the total payment amount of customers who come from the USA.
SQL: SELECT sum(payments.amount) FROM payments INNER JOIN customers ON payments.customernumber = customers.customernumber WHERE customers.country = 'USA'
Database: car_retails
Note: total payment refers to SUM(amount); no credit limit refers to creditlimit = 0; year(paymentdate) = '2003';
Question: What are the total payments of customers with no credit limit in 2003?
SQL: SELECT sum(amount) FROM payments WHERE strftime('%Y', paymentdate) = '2003' AND customernumber IN ( SELECT customernumber FROM customers WHERE creditlimit = 0 )
Database: car_retails
Note: cancelled order refers to status = 'Cancelled';
Question: Please list the name and phone number of the customer whose order was cancelled.
SQL: SELECT customers.customername, customers.phone FROM orders INNER JOIN customers ON orders.customernumber = customers.customernumber WHERE orders.status = 'Cancelled'
Database: car_retails
Note: French is a nationality of country = 'France'; cancelled orders refers to status = 'Cancelled';
Question: How many French customers shipped 2 orders which have been cancelled?
SQL: SELECT count(customers.country) FROM orders INNER JOIN customers ON orders.customernumber = customers.customernumber WHERE orders.status = 'Shipped' AND customers.country = 'France' GROUP BY customers.customernumber HAVING count(orders.status) = 2
Database: car_retails
Note: average total price = DIVIDE(MULTIPLY(quantityordered, priceeach)), COUNT(ordernumber)); German is a nationality of country = 'Germany'; shipped orders refers to status = 'Shipped';
Question: Please calculate the average total price of shipped orders from German customers.
SQL: SELECT sum(orderdetails.quantityordered * orderdetails.priceeach) / count(orders.ordernumber) FROM customers INNER JOIN orders ON customers.customernumber = orders.customernumber INNER JOIN orderdetails ON orders.ordernumber = orderdetails.ordernumber WHERE orders.status = 'Shipped' AND customers.country = 'Germany'
Database: car_retails
Note: Tokyo is a city; full name = firstname+lastname;
Question: List out full name of employees who are working in Tokyo?
SQL: SELECT employees.firstname, employees.lastname FROM employees INNER JOIN offices ON employees.officecode = offices.officecode WHERE offices.city = 'Tokyo'