db_id stringclasses 68 values | question stringlengths 24 325 | evidence stringlengths 0 580 | SQL stringlengths 23 728 |
|---|---|---|---|
synthea | Mention the description of the care plan of American patients. | American refers to ethnicity = 'american'; | SELECT DISTINCT T1.DESCRIPTION FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.ethnicity = 'american' |
synthea | What are the medical encounter ids of patients who were born in Pembroke MA US? | medical encounter ids careplans.ID; born in Pembroke MA US refers to birthplace = 'Pembroke MA US'; | SELECT DISTINCT T1.ENCOUNTER FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.birthplace = 'Pembroke MA US' |
synthea | List out the start date of the care plan of alive patients. | start of the care plan refers to careplans.START; alive patients refers to deathdate is null; | SELECT DISTINCT T1.START FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.deathdate IS NULL |
synthea | How many white patients have the reason code of 10509002? | white refers to race = 'white'; reason code of 10509002 refers to careplans.REASONCODE = '10509002'; | SELECT COUNT(DISTINCT T1.PATIENT) FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.race = 'white' AND T1.REASONCODE = '10509002' |
synthea | List out full name of patients who have "Diabetic diet" in the description of the care plan. | full name = first, last; Diabetic diet refers to careplans.DESCRIPTION = 'Diabetic diet'; | SELECT DISTINCT T2.first, T2.last FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.DESCRIPTION = 'Diabetic diet' |
synthea | List out the stop date of the care plan of dead patients. | stop date of the care plan refers to careplans.STOP; dead patients refers to deathdate is not null; | SELECT DISTINCT T1.STOP FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.deathdate IS NOT NULL AND T1.STOP IS NOT NULL |
synthea | How many Italian patients have the care plan code of 304510005? | Italian patients refers to ethnicity = 'italian'; | SELECT COUNT(DISTINCT T2.patient) FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.ethnicity = 'italian' AND T1.CODE = '304510005' |
synthea | List the full names of patients with nut allergy. | full names = first, last; nut allergy refers to allergies.DESCRIPTION = 'Allergy to nut'; | SELECT DISTINCT T1.first, T1.last FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Allergy to nut' |
synthea | Describe the condition of patient Wilmer Koepp. | SELECT T2.DESCRIPTION FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Wilmer' AND T1.last = 'Koepp' | |
synthea | Among the patients with viral sinusitis condition, which patient's gender is most affected? Provide the number for each respectively. | viral sinusitis condition refers to conditions.DESCRIPTION = 'Viral sinusitis (disorder)'; gender that is most affected refers to MAX(COUNT(gender WHERE conditions.DESCRIPTION = 'Viral sinusitis (disorder)')); | SELECT SUM(CASE WHEN T1.gender = 'F' THEN 1 ELSE 0 END), SUM(CASE WHEN T1.gender = 'M' THEN 1 ELSE 0 END) FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Viral sinusitis (disorder)' |
synthea | Which conditions the patient has when receiving the IPV immunization? | IPV immunization refers to immunizations.DESCRIPTION = 'IPV'; | SELECT DISTINCT T2.DESCRIPTION FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT INNER JOIN immunizations AS T3 ON T1.patient = T3.PATIENT WHERE T3.DESCRIPTION = 'IPV' |
synthea | List the patient ids whose disease has the most occurrences. | patient ids refers to patients.patient; disease with the most occurrence refers to MAX(all_prevalences.OCCURENCES); | SELECT T1.patient FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT INNER JOIN all_prevalences AS T3 ON T3.ITEM = T2.DESCRIPTION ORDER BY T3.OCCURRENCES DESC LIMIT 1 |
synthea | List all the full names of patients with a condition described as cystitis. | full names = first, last; condition described as cystitis refers to conditions.DESCRIPTION = ''Cystitis'; | SELECT DISTINCT T1.first, T1.last FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.patient WHERE T2.DESCRIPTION = 'Cystitis' |
synthea | How many male patients have been described as immune to quadrivalent HPV? | male refers to gender = 'M'; immune to quadrivalent HPV refers to immunizations.DESCRIPTION = 'HPV quadrivalent'; | SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN immunizations AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'HPV quadrivalent' AND T1.gender = 'M' |
synthea | Indicate the start date of patient Walter Bahringer's care plan. | start date of the care plan refers to careplans.START; | SELECT DISTINCT T2.start FROM patients AS T1 INNER JOIN careplans AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Walter' AND T1.last = 'Bahringer' |
synthea | Describe the care plans of patient Major D'Amore's plan of care. | SELECT DISTINCT T2.DESCRIPTION FROM patients AS T1 INNER JOIN careplans AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Major' AND T1.last = 'D''Amore' | |
synthea | Calculate the percentage of male patients with viral sinusitis condition. | 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)'; | SELECT CAST(SUM(CASE WHEN T1.gender = 'M' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.patient) FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Viral sinusitis (disorder)' |
synthea | Among the patients who have been using Penicillin V Potassium 250 MG, what percentage of patients are female? | 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'; | SELECT CAST(SUM(CASE WHEN T1.gender = 'F' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.patient) FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Penicillin V Potassium 250 MG' |
synthea | Among the white patients, what is the average body height of the patients? | white refers to race = 'white'; average body height = AVG(observations.VALUE WHERE observations.DESCRIPTION = 'Body Height'); body height refers to observations.DESCRIPTION = 'Body Height'; | SELECT AVG(T1.VALUE) FROM observations AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.race = 'white' AND T1.DESCRIPTION = 'Body Height' |
synthea | Indicate the care plan needed for the patient living at 179 Sydni Roads, Taunton, MA 02780 US. | living at 179 Sydni Roads, Taunton, MA 02780 US refers to address = '179 Sydni Roads Taunton MA 02780 US'; | SELECT T1.DESCRIPTION FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.address = '179 Sydni Roads Taunton MA 02780 US' |
synthea | Provide the allergen of the Dominican patient named Dirk Languish. | allergen refers to allergies.DESCRIPTION; | SELECT T1.DESCRIPTION FROM allergies AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.first = 'Dirk' AND T2.last = 'Langosh' AND T2.ethnicity = 'dominican' |
synthea | How many patients who are allergic to peanuts have asthma? | allergic to peanuts refers to allergies.DESCRIPTION = 'Allergy to peanuts'; asthma refers to conditions.DESCRIPTION = 'Asthma'; | SELECT COUNT(DISTINCT T2.patient) FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient INNER JOIN allergies AS T3 ON T2.patient = T3.PATIENT WHERE T1.DESCRIPTION = 'Asthma' AND T3.DESCRIPTION = 'Allergy to peanuts' |
synthea | Provide the social security number of the patient with the highest systolic blood pressure. | social security number refers to ssn; highest systolic blood pressure refers to MAX(observations.VALUE WHERE observations.DESCRIPTION = 'Systolic Blood Pressure'); | SELECT T2.ssn FROM observations AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.DESCRIPTION = 'Systolic Blood Pressure' ORDER BY T1.VALUE DESC LIMIT 1 |
synthea | What is the care plan description of the prevalent disease with the highest prevalence percentage? | highest prevalence percentage refers to MAX(PREVALENCE PERCENTAGE); | SELECT T4.DESCRIPTION FROM all_prevalences AS T1 INNER JOIN conditions AS T2 ON T2.DESCRIPTION = T1.ITEM INNER JOIN encounters AS T3 ON T2.ENCOUNTER = T3.ID INNER JOIN careplans AS T4 ON T4.ENCOUNTER = T3.ID ORDER BY T1."PREVALENCE PERCENTAGE" DESC LIMIT 1 |
synthea | What is the care plan for the patient with social security number 999-15-3685? | social security number refers to ssn; ssn = '999-15-3685'; | SELECT DISTINCT T1.DESCRIPTION FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.ssn = '999-15-3685' |
synthea | List 5 patients' name that need medication due to streptococcal sore throat disorder. | patients name = first, last; streptococcal sore throat disorder refers to medications.REASONDESCRIPTION = 'Streptococcal sore throat (disorder)'; | SELECT DISTINCT T2.first, T2.last FROM medications AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.REASONDESCRIPTION = 'Streptococcal sore throat (disorder)' LIMIT 5 |
synthea | Among the male patients, list down 5 birth dates of patients taking the medication "Penicillin V Potassium 250 MG". | male patients refers to gender = 'M'; Penicillin V Potassium 250 MG refers to medications.DESCRIPTION = 'Penicillin V Potassium 250 MG'; | SELECT DISTINCT T2.birthdate FROM medications AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.DESCRIPTION = 'Penicillin V Potassium 250 MG' AND T2.gender = 'M' LIMIT 5 |
synthea | 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. | 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))); | SELECT DISTINCT T2.first, T2.last FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient INNER JOIN all_prevalences AS T3 ON T1.DESCRIPTION = T3.ITEM WHERE T2.ethnicity = 'irish' AND 100 * CAST(T3.OCCURRENCES AS REAL) / ( SELECT AVG(OCCURRENCES) FROM all_prevalences ) > 96 |
synthea | What is the difference between the number of married patients and the number of single patients with diabetes? | 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'; | SELECT SUM(CASE WHEN T2.marital = 'M' THEN 1 ELSE 0 END) - SUM(CASE WHEN T2.marital = 'S' THEN 1 ELSE 0 END) FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.DESCRIPTION = 'Diabetes' |
car_retails | List the country and how many customers are there. | SELECT country, COUNT(customerNumber) FROM customers GROUP BY country | |
car_retails | How many employees are there in Sydney? | sales agent and sales representative are synonyms; Sydney is a city; | SELECT COUNT(employeeNumber) FROM employees WHERE officeCode = ( SELECT officeCode FROM offices WHERE city = 'Sydney' ) |
car_retails | Which sales representatives in New York city whose leader is Anthony Bow with the employee number is 1143? Indicate their employee numbers. | reportsTO' is the leader of the 'employeeNumber'; | SELECT T1.employeeNumber FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T1.reportsTo = 1143 AND T2.city = 'NYC' |
car_retails | What is the average, highest and lowest annual payments collected between 1/1/2003 to 12/31/2005? | paymentDate BETWEEN '2003-01-01' AND '2005-12-31'; average annual payments = DIVIDE(SUM(amount), 3); | SELECT CAST(SUM(T1.amount) AS REAL) / 3, MAX(T1.amount) , MIN(T1.amount) FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.paymentDate BETWEEN '2003-01-01' AND '2005-12-31' |
car_retails | Of all the classic cars, with a product scale of 1:18, which product is the most ordered product by customers? | classic car is a product line; most ordered product refers to MAX(quantityOrdered); | SELECT T1.productName FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode WHERE T1.productScale = '1:18' AND T1.productLine = 'Classic Cars' GROUP BY T1.productName ORDER BY SUM(T2.quantityOrdered) DESC LIMIT 1 |
car_retails | How many different orders with a total price greater than 4000 are cancelled? | total price = MULTIPLY(quantityOrdered, priceEach) > 4000; cancelled orders refer to status = 'Cancelled'; | SELECT COUNT(DISTINCT T1.orderNumber) FROM orderdetails AS T1 INNER JOIN orders AS T2 ON T1.orderNumber = T2.orderNumber WHERE T1.quantityOrdered * T1.priceEach > 4000 AND T2.status = 'Cancelled' |
car_retails | What is the total value of cancelled orders? | total value = SUM(MULTIPLY(quantityOrdered, priceEach)); cancelled orders refers to status = 'Cancelled'; | SELECT SUM(T1.quantityOrdered * T1.priceEach) FROM orderdetails AS T1 INNER JOIN orders AS T2 ON T1.orderNumber = T2.orderNumber WHERE T2.status = 'Cancelled' |
car_retails | Please calculate the total value of Motorcycles orders. | Motorcycle is a product line; total value = SUM(MULTIPLY(quantityOrdered, priceEach)); | SELECT SUM(T1.quantityOrdered * T1.priceEach) FROM orderdetails AS T1 INNER JOIN products AS T2 ON T1.productCode = T2.productCode WHERE T2.productLine = 'Motorcycles' |
car_retails | How many Planes orders were there? | Planes is a product line; | SELECT COUNT(T1.productCode) FROM orderdetails AS T1 INNER JOIN products AS T2 ON T1.productCode = T2.productCode WHERE T2.productLine = 'Planes' |
car_retails | How many orders which expected profits greater than 100? | expected profits greater than 100 = (SUBTRACT(msrp, buyPrice))>100; | SELECT COUNT(T1.productCode) FROM orderdetails AS T1 INNER JOIN products AS T2 ON T1.productCode = T2.productCode WHERE T2.MSRP - T2.buyPrice > 100 |
car_retails | Please list different customer names with the payment amount of over 50,000. | amount > 50000; | SELECT DISTINCT T2.customerName FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.amount > 50000 |
car_retails | Please calculate the total payment amount of customers who come from the USA. | USA is a country; total amount payment refers to SUM(amount); | SELECT SUM(T1.amount) FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T2.country = 'USA' |
car_retails | Please list the name and phone number of the customer whose order was cancelled. | cancelled order refers to status = 'Cancelled'; | SELECT T2.customerName, T2.phone FROM orders AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.status = 'Cancelled' |
car_retails | How many French customers shipped 2 orders which have been cancelled? | French is a nationality of country = 'France'; cancelled orders refers to status = 'Cancelled'; | SELECT COUNT(T2.country) FROM orders AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.status = 'Shipped' AND T2.country = 'France' GROUP BY T2.customerNumber HAVING COUNT(T1.status) = 2 |
car_retails | Please calculate the average total price of shipped orders from German customers. | average total price = DIVIDE(MULTIPLY(quantityOrdered, priceEach)), COUNT(orderNumber)); German is a nationality of country = 'Germany'; shipped orders refers to status = 'Shipped'; | SELECT SUM(T3.quantityOrdered * T3.priceEach) / COUNT(T2.orderNumber) FROM customers AS T1 INNER JOIN orders AS T2 ON T1.customerNumber = T2.customerNumber INNER JOIN orderdetails AS T3 ON T2.orderNumber = T3.orderNumber WHERE T2.status = 'Shipped' AND T1.country = 'Germany' |
car_retails | List out full name of employees who are working in Tokyo? | Tokyo is a city; full name = firstName+lastName; | SELECT T1.firstName, T1.lastName FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T2.city = 'Tokyo' |
car_retails | How many Sales Rep who are working in Tokyo? List out email and full name of those employees. | Sales Rep is a job title; Tokyo is a city; full name = firstName+lastName; | SELECT T1.firstName, T1.lastName, T1.email FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T2.city = 'Tokyo' AND T1.jobTitle = 'Sales Rep' |
car_retails | State the email of those who are staff of Murphy Diane whose number is 1002 and living in San Francisco | staff of refers to reportsTO; San Francisco is a city; | SELECT T1.email FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T1.reportsTo = 1002 AND T2.city = 'San Francisco' |
car_retails | Determine the email and Code of employee who are working at United State, state MA | code of employee refers to employeeNumber; United States of America refers to country = 'USA'; | SELECT T1.email, T1.employeeNumber FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T2.state = 'MA' AND T2.country = 'USA' |
car_retails | How many Sales Manager who are working in Sydney? List out their email. | Sales Manager is a job title; Sydney is a city; | SELECT T1.email FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T1.jobTitle LIKE '%Sales Manager%' AND T2.city = 'Sydney' |
car_retails | How many employees who are living in Australia and have the credit limit under 200000? State their email address and countries where they are working. | Australia is a country; creditLimit < 20000; | SELECT T2.email, T3.country FROM customers AS T1 INNER JOIN employees AS T2 ON T1.salesRepEmployeeNumber = T2.employeeNumber INNER JOIN offices AS T3 ON T2.officeCode = T3.officeCode WHERE T3.country = 'Australia' AND T1.creditLimit < 200000 AND T2.jobTitle = 'Sales Rep' |
car_retails | How many Australian customers who have credit line under 220000? | Australian is a nationality of country = 'Australia'; credit line refers to creditLimit; creditLimit < 220000; | SELECT COUNT(creditLimit) FROM customers WHERE creditLimit < 220000 AND country = 'Australia' |
car_retails | List out 3 customer numbers who have highest amount payment | amount of payment refers to amount; | SELECT customerNumber FROM payments ORDER BY amount DESC LIMIT 3 |
car_retails | List out full name of employees who are working in Boston? | full name = contactFirstName, contactLastName; Boston is a city; | SELECT T1.firstName, T1.lastName FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T2.city = 'Boston' |
car_retails | State top 3 emails of UK Sales Rep who have the highest credit limit. | UK is a country; Sales Rep is a job title; | SELECT T2.email FROM customers AS T1 INNER JOIN employees AS T2 ON T1.salesRepEmployeeNumber = T2.employeeNumber WHERE T2.jobTitle = 'Sales Rep' AND T1.country = 'UK' GROUP BY T1.customerName, T2.email ORDER BY SUM(T1.creditLimit) DESC LIMIT 3 |
car_retails | How many customers who are in Norway and have credit line under 220000? | Norway is a country; credit line refers to creditLimit; creditLimit<220000; | SELECT COUNT(creditLimit) FROM customers WHERE creditLimit < 220000 AND country = 'Norway' |
car_retails | List out full name and email of employees who are working in Paris? | full name = firstName+LastName; Paris is a city; | SELECT T1.firstName, T1.lastName, T1.email FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T2.city = 'Paris' |
car_retails | List the product code of the top five motorcycles, by descending order, the number of quantity in stock. | motorcycle is a product line; | SELECT productCode, quantityInStock FROM products WHERE productLine = 'Motorcycles' ORDER BY quantityInStock DESC LIMIT 5 |
car_retails | Among the German customers, how many of the them has credit limit of zero? | German is a nationality of country = 'Germany'; CREDITLIMIT = 0 | SELECT COUNT(customerNumber) FROM customers WHERE creditLimit = 0 AND country = 'Germany' |
car_retails | What is the average actual profit by 1937 Lincoln Berline? | average actual profit = AVG(SUBTRACT(priceEach, buyPrice)); 1937 Lincoln Berline is a product name; | SELECT SUM(T1.priceEach - T2.buyPrice) / COUNT(*) FROM orderdetails AS T1 INNER JOIN products AS T2 ON T1.productCode = T2.productCode WHERE T2.productName = '1937 Lincoln Berline' |
car_retails | Among the motorcycles with product scale of 1:10, which of them is the most ordered by American customers? | motorcycle is a product line; American is a nationality of country = 'USA'; | SELECT T1.productName FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode INNER JOIN orders AS T3 ON T2.orderNumber = T3.orderNumber INNER JOIN customers AS T4 ON T3.customerNumber = T4.customerNumber WHERE T1.productLine = 'Motorcycles' AND T1.productScale = '1:10' AND T4.country = 'USA' GROUP BY T1.productName ORDER BY SUM(T2.quantityOrdered) DESC LIMIT 1 |
car_retails | Between 8/1/2003 and 8/30/2004, how many checks were issued by Mini Gifts Distributors Ltd.? Please list their check numbers. | paymentDate BETWEEN '2003-08-01' AND '2004-08-30'; Mini Gifts Distributors Ltd. Is a customer name; | SELECT T1.checkNumber FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.paymentDate >= '2003-08-01' AND T1.paymentDate <= '2004-08-30' AND T2.customerName = 'Mini Gifts Distributors Ltd.' |
car_retails | For the planes which has the hightest total price, how much it exceeds the average? | plane is a product line; total price = MULTIPLY(quantityOrdered, priceEach); how much the total price exceeds the average = SUBTRACT(MAX(MULTIPLY(quantityOrdered, priceEach))), AVG(priceEach)); | SELECT MAX(quantityOrdered * priceEach) - AVG(priceEach) FROM orderdetails WHERE productCode IN ( SELECT productCode FROM products WHERE productLine = 'Planes' ) |
car_retails | What is the total value of shipped vintage car orders from 2003-2004? | total value = SUM(MULTIPLY(quantityOrdered, priceEach)); shipped orders refers to status = 'Shipped'; vintage car is a product line; year(orderDate) between 2003 and 2004; | SELECT SUM(T2.priceEach * T2.quantityOrdered) FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode INNER JOIN orders AS T3 ON T2.orderNumber = T3.orderNumber WHERE T3.status = 'Shipped' AND T3.orderDate BETWEEN '2003-01-01' AND '2004-12-31' |
car_retails | Who is the sales agent of the customer who has made the highest payment? Include the full names of employee and his/her supervisor. | payment refers to amount; full name = firstName+lastName; supervisor refers to reportsTO; 'reportsTO' is the leader of the 'employeeNumber'; | SELECT T1.firstName, T1.lastName, T1.reportsTo FROM employees AS T1 INNER JOIN customers AS T2 ON T1.employeeNumber = T2.salesRepEmployeeNumber INNER JOIN payments AS T3 ON T2.customerNumber = T3.customerNumber ORDER BY T3.amount DESC LIMIT 1 |
car_retails | What is the highest amount of order made by the sales representative in Boston? Please give the name of the product and amount. | Boston is a city; amount of order = MULTIPLY(quantityOrdered, priceEach); | SELECT T2.productName, T1.quantityOrdered * T1.priceEach FROM orderdetails AS T1 INNER JOIN products AS T2 ON T1.productCode = T2.productCode INNER JOIN orders AS T3 ON T1.orderNumber = T3.orderNumber INNER JOIN customers AS T4 ON T3.customerNumber = T4.customerNumber WHERE T4.city = 'Boston' AND T4.salesRepEmployeeNumber IN ( SELECT employeeNumber FROM employees WHERE jobTitle = 'Sales Rep' ) ORDER BY T1.quantityOrdered DESC LIMIT 1 |
car_retails | What is the total actual profit gained from orders made by American customers from 2003-01-06 to 2005-05-09? | total actual profit = SUM(SUBTRACT(priceEach, buyPrice)); American is a nationality of country = 'USA'; orderDate BETWEEN '2003-01-06' AND '2005-05-09'; | SELECT SUM(T2.priceEach - T1.buyPrice) FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode INNER JOIN orders AS T3 ON T2.orderNumber = T3.orderNumber INNER JOIN customers AS T4 ON T3.customerNumber = T4.customerNumber WHERE T3.orderDate > '2003-01-05' AND T3.orderDate < '2005-05-10' |
car_retails | What is the phone number of all companies where the last name of the contact person starts with the letter M and are not from Germany? | last name of contact person starts with M refers to lastName LIKE 'M%'; Germany is a country; not from Germany refers to country<>'Germany'; | SELECT phone FROM customers WHERE contactLastName LIKE 'M%' AND country != 'Germany' |
car_retails | Calculate the average amount of payments made by customers during the first half of 2004. | average amount of payments = DIVIDE(SUM(amount), COUNT(customerNumber); first half of 2014 refers to paymentDate > = '2004-01-01' AND paymentDate < '2004-07-01; | SELECT AVG(amount) FROM payments WHERE paymentDate BETWEEN '2004-01-01' AND '2004-06-30' |
car_retails | Of all the orders placed and shipped throughout the year 2005, what percentage of those orders corresponds to customer number 186? | shipped orders refers to status = 'shipped'; year(shippedDate) = 2005; percentage = DIVIDE(SUM(customerNumber = 186)), COUNT(orderNumber)) as percentage; | SELECT CAST(SUM(CASE WHEN customerNumber = 186 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(orderNumber) FROM orders WHERE status = 'Shipped' AND shippedDate BETWEEN '2005-01-01' AND '2005-12-31' |
car_retails | How many customers with a canceled shipment have a credit limit greater than 115,000? | cancelled shipment refers to status = 'cancelled'; creditLimit > 115000; | SELECT COUNT(T1.customerNumber) FROM customers AS T1 INNER JOIN orders AS T2 ON T1.customerNumber = T2.customerNumber WHERE T2.status = 'Cancelled' AND T1.creditLimit > 115000 |
car_retails | On what date did the customer with the lowest credit limit serviced by sales representative Barry Jones make payments for his/her orders? | SELECT T3.paymentDate FROM employees AS T1 INNER JOIN customers AS T2 ON T1.employeeNumber = T2.salesRepEmployeeNumber INNER JOIN payments AS T3 ON T2.customerNumber = T3.customerNumber WHERE T1.firstName = 'Barry' AND T1.lastName = 'Jones' AND T1.jobTitle = 'Sales Rep' ORDER BY T2.creditLimit ASC LIMIT 1 | |
car_retails | To whom does the employee have to inform that is the sales representative of the French customer? | inform refers to reportsTo; 'reportsTO' is the leader of the 'employeeNumber'; France is a country; country = 'France'; | SELECT T1.reportsTo FROM employees AS T1 INNER JOIN customers AS T2 ON T1.employeeNumber = T2.salesRepEmployeeNumber WHERE T2.country = 'France' |
car_retails | What is the full address of the customer who commented that DHL be used for the order that was shipped on April 4, 2005? | full address = addressLine1+addressLine2; shippedDate = '2005-04-04'; | SELECT T1.addressLine1, T1.addressLine2 FROM customers AS T1 INNER JOIN orders AS T2 ON T1.customerNumber = T2.customerNumber WHERE T2.shippedDate = '2005-04-04' AND T2.status = 'Shipped' |
car_retails | What is the full address of the office where the employee who is a sales representative for the customer whose business is located in the city of New York works? | full address = addressLine1 + addressLine2; NYC is a shortname of New York City. | SELECT T2.addressLine1, T2.addressLine2 FROM employees AS T1 INNER JOIN customers AS T2 ON T1.employeeNumber = T2.salesRepEmployeeNumber INNER JOIN offices AS T3 ON T1.officeCode = T3.officeCode WHERE T2.city = 'NYC' AND T1.jobTitle = 'Sales Rep' |
car_retails | What is the full address of the office where 4 people work and one of them is Sales Representation? | full address = addressLine1+addressLine2; Sales Manager is a job title; | SELECT T1.addressLine1, T1.addressLine2 FROM customers AS T1 INNER JOIN employees AS T2 ON T1.salesRepEmployeeNumber = T2.employeeNumber WHERE T2.jobTitle = 'Sales Rep' |
car_retails | What profit can the seller Carousel DieCast Legends make from the sale of the product described as "The perfect holiday or anniversary gift for executives"? | seller and product vendor are synonyms; Carousel DieCast Legends is a product vendor; profit = SUM(SUBTRACT(msrp, buyPrice)); | SELECT SUM(T2.MSRP - T2.buyPrice) FROM productlines AS T1 INNER JOIN products AS T2 ON T1.productLine = T2.productLine WHERE T2.productVendor = 'Carousel DieCast Legends' AND T1.textDescription LIKE '%perfect holiday or anniversary gift for executives%' |
car_retails | Of the clients whose businesses are located in the city of Boston, calculate which of them has a higher average amount of payment. | average amount payment = AVG(amount); | SELECT T1.customerNumber FROM customers AS T1 INNER JOIN payments AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.city = 'Boston' GROUP BY T1.customerNumber ORDER BY SUM(T2.amount) / COUNT(T2.paymentDate) DESC LIMIT 1 |
car_retails | Calculate the total quantity ordered for 18th Century Vintage Horse Carriage and the average price. | 18th Century Vintage Horse Carriage is a product name; average price = AVG(priceEach); | SELECT SUM(T2.quantityOrdered) , SUM(T2.quantityOrdered * T2.priceEach) / SUM(T2.quantityOrdered) FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode WHERE T1.productName = '18th Century Vintage Horse Carriage' |
car_retails | How many kinds of products did order No. 10252 contain? | Products refer to productCode; | SELECT COUNT(t.productCode) FROM orderdetails t WHERE t.orderNumber = '10252' |
car_retails | Who is the sales representative that made the order which was sent to 25 Maiden Lane, Floor No. 4? | Sales representative is an employee; | SELECT T2.firstName, T2.lastName FROM customers AS T1 INNER JOIN employees AS T2 ON T1.salesRepEmployeeNumber = T2.employeeNumber WHERE T1.addressLine1 = '25 Maiden Lane' AND T1.addressLine2 = 'Floor No. 4' |
car_retails | Where's Foon Yue Tseng's office located at? Give the detailed address. | Detailed address comprises addressLine1 and addressLine2; | SELECT T1.addressLine1, T1.addressLine2 FROM offices AS T1 INNER JOIN employees AS T2 ON T1.officeCode = T2.officeCode WHERE T2.firstName = 'Foon Yue' AND T2.lastName = 'Tseng' |
car_retails | How many products with the highest expected profits were sold in total? | Products refer to productCode; Expected profits = SUBTRACT(MSRP, buyPrice); | SELECT SUM(t2.quantityOrdered) FROM orderdetails AS t2 INNER JOIN ( SELECT t1.productCode FROM products AS t1 ORDER BY t1.MSRP - t1.buyPrice DESC LIMIT 1 ) AS t3 ON t2.productCode = t3.productCode |
car_retails | How much did Petit Auto pay on 2004-08-09? | Petit Auto is name of customer; paymentDate = '2004-08-09'; | SELECT t1.amount FROM payments AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t2.customerName = 'Petit Auto' AND t1.paymentDate = '2004-08-09' |
car_retails | What was the contact name for the check "NR157385"? | Contact name refers to customerName; | SELECT t2.contactFirstName, t2.contactLastName FROM payments AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t1.checkNumber = 'NR157385' |
car_retails | Which customer made the order No. 10160? Give the contact name. | SELECT t2.contactFirstName, t2.contactLastName FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t1.orderNumber = '10160' | |
car_retails | Where was the order No. 10383 shipped to? Show me the address. | Address comprises addressLine1 and addressLine2; | SELECT t2.addressLine1, t2.addressLine2 FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t1.orderNumber = '10383' |
car_retails | For the productline where the product No.S18_2949 was produced, what's the text description for that product line? | SELECT t1.textDescription FROM productlines AS t1 INNER JOIN products AS t2 ON t1.productLine = t2.productLine WHERE t2.productCode = 'S18_2949' | |
car_retails | If Dragon Souveniers, Ltd. aren't satisfied with their order and want to send a complain e-mail, which e-mail address should they send to? | E-mail address belongs to employee; customerName = 'Dragon Souveniers, Ltd.'; | SELECT t2.email FROM customers AS t1 INNER JOIN employees AS t2 ON t1.salesRepEmployeeNumber = t2.employeeNumber WHERE t1.customerName = 'Dragon Souveniers, Ltd.' |
car_retails | How many French customers does Gerard Hernandez take care of? | Gerakd Hermandez is an employee; French customer refers to customer from France where country = 'France' | SELECT COUNT(t1.customerNumber) FROM customers AS t1 INNER JOIN employees AS t2 ON t1.salesRepEmployeeNumber = t2.employeeNumber WHERE t1.country = 'France' AND t2.firstName = 'Gerard' AND t2.lastName = 'Hernandez' |
car_retails | What was the latest order that customer No.114 made? Give the name of the product. | The latest refers to the most recent orderDate; | SELECT t3.productName FROM orderdetails AS t1 INNER JOIN orders AS t2 ON t1.orderNumber = t2.orderNumber INNER JOIN products AS t3 ON t1.productCode = t3.productCode WHERE t2.customerNumber = '114' ORDER BY t2.orderDate DESC LIMIT 1 |
car_retails | For the product No. S18_3482 in the Order No.10108, how much discount did the customer have? | DIVIDE(SUBTRACT(MSRP, priceEach)), MSRP); product No. S18_3482 refers to productCode = 'S18_3482' | SELECT (t1.MSRP - t2.priceEach) / t1.MSRP FROM products AS t1 INNER JOIN orderdetails AS t2 ON t1.productCode = t2.productCode WHERE t1.productCode = 'S18_3482' AND t2.orderNumber = '10108' |
car_retails | To whom does Steve Patterson report? Please give his or her full name. | reportsTO' is the leader of the 'employeeNumber'; | SELECT t2.firstName, t2.lastName FROM employees AS t1 INNER JOIN employees AS t2 ON t2.employeeNumber = t1.reportsTo WHERE t1.firstName = 'Steve' AND t1.lastName = 'Patterson' |
car_retails | How do I contact the President of the company? | President refers to the jobTitle; | SELECT t.email FROM employees t WHERE t.jobTitle = 'President' |
car_retails | Who is the sales representitive of Muscle Machine Inc? Please give the employee's full name. | Sales representative refers to jobTitle = 'Sales Rep'; Muscle Machine Inc is name of customer; | SELECT t2.firstName, t2.lastName FROM customers AS t1 INNER JOIN employees AS t2 ON t1.salesRepEmployeeNumber = t2.employeeNumber WHERE t1.customerName = 'Muscle Machine Inc' |
car_retails | If I'm from the Muscle Machine Inc, to which e-mail adress should I write a letter if I want to reach the superior of my sales representitive? | Muscle Machine Inc is name of customer; superior refers to 'reportsTO', who is the leader of the 'employeeNumber' | SELECT t2.email FROM customers AS t1 INNER JOIN employees AS t2 ON t1.salesRepEmployeeNumber = t2.employeeNumber WHERE t1.customerName = 'Muscle Machine Inc' |
car_retails | Please list all the customers that have Steve Patterson as their sales representitive. | Steve Patterson is an employee; | SELECT t1.customerName FROM customers AS t1 INNER JOIN employees AS t2 ON t1.salesRepEmployeeNumber = t2.employeeNumber WHERE t2.firstName = 'Steve' AND t2.lastName = 'Patterson' |
car_retails | How many customers have an employee who reports to William Patterson as their sales representitive? | reportsTO' is the leader of the 'employeeNumber'; | SELECT COUNT(t1.customerNumber) FROM customers AS t1 INNER JOIN employees AS t2 ON t1.salesRepEmployeeNumber = t2.employeeNumber WHERE t2.firstName = 'William' AND t2.lastName = 'Patterson' |
car_retails | Please list the phone numbers of the top 3 customers that have the highest credit limit and have Leslie Jennings as their sales representitive. | SELECT t1.phone FROM customers AS t1 INNER JOIN employees AS t2 ON t1.salesRepEmployeeNumber = t2.employeeNumber WHERE t2.firstName = 'Leslie' AND t2.lastName = 'Jennings' ORDER BY t1.creditLimit DESC LIMIT 3 | |
car_retails | How many sales representitives are based in the offices in the USA? | Sales representative refers to jobTitle = 'Sales Rep'; country = 'USA'; | SELECT COUNT(t1.employeeNumber) FROM employees AS t1 INNER JOIN offices AS t2 ON t1.officeCode = t2.officeCode WHERE t2.country = 'USA' AND t1.jobTitle = 'Sales Rep' |
car_retails | Where can I find the office of the President of the company? | Where can I find the office refers to address, comprising of addressLine1 and addressLine2; President is a jobTitle | SELECT t2.addressLine1, t2.addressLine2 FROM employees AS t1 INNER JOIN offices AS t2 ON t1.officeCode = t2.officeCode WHERE t1.jobTitle = 'President' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.