1sf/bird-sql-train-with-schema huggingface dataset:
Database: synthea
Tables: all_prevalences, patients, encounters, allergies, careplans, conditions, immunizations, medications, observations, procedures, claims
Columns (table index, column name): -1, *, 0, ITEM, 0, POPULATION TYPE, 0, OCCURRENCES, 0, POPULATION COUNT, 0, PREVALENCE RATE, 0, PREVALENCE PERCENTAGE, 1, patient, 1, birthdate, 1, deathdate, 1, ssn, 1, drivers, 1, passport, 1, prefix, 1, first, 1, last, 1, suffix, 1, maiden, 1, marital, 1, race, 1, ethnicity, 1, gender, 1, birthplace, 1, address, 2, ID, 2, DATE, 2, PATIENT, 2, CODE, 2, DESCRIPTION, 2, REASONCODE, 2, REASONDESCRIPTION, 3, START, 3, STOP, 3, PATIENT, 3, ENCOUNTER, 3, CODE, 3, DESCRIPTION, 4, ID, 4, START, 4, STOP, 4, PATIENT, 4, ENCOUNTER, 4, CODE, 4, DESCRIPTION, 4, REASONCODE, 4, REASONDESCRIPTION, 5, START, 5, STOP, 5, PATIENT, 5, ENCOUNTER, 5, CODE, 5, DESCRIPTION, 6, DATE, 6, PATIENT, 6, ENCOUNTER, 6, CODE, 6, DESCRIPTION, 7, START, 7, STOP, 7, PATIENT, 7, ENCOUNTER, 7, CODE, 7, DESCRIPTION, 7, REASONCODE, 7, REASONDESCRIPTION, 8, DATE, 8, PATIENT, 8, ENCOUNTER, 8, CODE, 8, DESCRIPTION, 8, VALUE, 8, UNITS, 9, DATE, 9, PATIENT, 9, ENCOUNTER, 9, CODE, 9, DESCRIPTION, 9, REASONCODE, 9, REASONDESCRIPTION, 10, ID, 10, PATIENT, 10, BILLABLEPERIOD, 10, ORGANIZATION, 10, ENCOUNTER, 10, DIAGNOSIS, 10, TOTAL
Question: Among the male patients, list down 5 birth dates of patients taking the medication "Penicillin V Potassium 250 MG".
Evidence: male patients refers to gender = 'M'; Penicillin V Potassium 250 MG refers to medications.DESCRIPTION = 'Penicillin V Potassium 250 MG';
SQL: 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
Database: synthea
Tables: all_prevalences, patients, encounters, allergies, careplans, conditions, immunizations, medications, observations, procedures, claims
Columns (table index, column name): -1, *, 0, ITEM, 0, POPULATION TYPE, 0, OCCURRENCES, 0, POPULATION COUNT, 0, PREVALENCE RATE, 0, PREVALENCE PERCENTAGE, 1, patient, 1, birthdate, 1, deathdate, 1, ssn, 1, drivers, 1, passport, 1, prefix, 1, first, 1, last, 1, suffix, 1, maiden, 1, marital, 1, race, 1, ethnicity, 1, gender, 1, birthplace, 1, address, 2, ID, 2, DATE, 2, PATIENT, 2, CODE, 2, DESCRIPTION, 2, REASONCODE, 2, REASONDESCRIPTION, 3, START, 3, STOP, 3, PATIENT, 3, ENCOUNTER, 3, CODE, 3, DESCRIPTION, 4, ID, 4, START, 4, STOP, 4, PATIENT, 4, ENCOUNTER, 4, CODE, 4, DESCRIPTION, 4, REASONCODE, 4, REASONDESCRIPTION, 5, START, 5, STOP, 5, PATIENT, 5, ENCOUNTER, 5, CODE, 5, DESCRIPTION, 6, DATE, 6, PATIENT, 6, ENCOUNTER, 6, CODE, 6, DESCRIPTION, 7, START, 7, STOP, 7, PATIENT, 7, ENCOUNTER, 7, CODE, 7, DESCRIPTION, 7, REASONCODE, 7, REASONDESCRIPTION, 8, DATE, 8, PATIENT, 8, ENCOUNTER, 8, CODE, 8, DESCRIPTION, 8, VALUE, 8, UNITS, 9, DATE, 9, PATIENT, 9, ENCOUNTER, 9, CODE, 9, DESCRIPTION, 9, REASONCODE, 9, REASONDESCRIPTION, 10, ID, 10, PATIENT, 10, BILLABLEPERIOD, 10, ORGANIZATION, 10, ENCOUNTER, 10, DIAGNOSIS, 10, TOTAL
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.
Evidence: 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)));
SQL: 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
Database: synthea
Tables: all_prevalences, patients, encounters, allergies, careplans, conditions, immunizations, medications, observations, procedures, claims
Columns (table index, column name): -1, *, 0, ITEM, 0, POPULATION TYPE, 0, OCCURRENCES, 0, POPULATION COUNT, 0, PREVALENCE RATE, 0, PREVALENCE PERCENTAGE, 1, patient, 1, birthdate, 1, deathdate, 1, ssn, 1, drivers, 1, passport, 1, prefix, 1, first, 1, last, 1, suffix, 1, maiden, 1, marital, 1, race, 1, ethnicity, 1, gender, 1, birthplace, 1, address, 2, ID, 2, DATE, 2, PATIENT, 2, CODE, 2, DESCRIPTION, 2, REASONCODE, 2, REASONDESCRIPTION, 3, START, 3, STOP, 3, PATIENT, 3, ENCOUNTER, 3, CODE, 3, DESCRIPTION, 4, ID, 4, START, 4, STOP, 4, PATIENT, 4, ENCOUNTER, 4, CODE, 4, DESCRIPTION, 4, REASONCODE, 4, REASONDESCRIPTION, 5, START, 5, STOP, 5, PATIENT, 5, ENCOUNTER, 5, CODE, 5, DESCRIPTION, 6, DATE, 6, PATIENT, 6, ENCOUNTER, 6, CODE, 6, DESCRIPTION, 7, START, 7, STOP, 7, PATIENT, 7, ENCOUNTER, 7, CODE, 7, DESCRIPTION, 7, REASONCODE, 7, REASONDESCRIPTION, 8, DATE, 8, PATIENT, 8, ENCOUNTER, 8, CODE, 8, DESCRIPTION, 8, VALUE, 8, UNITS, 9, DATE, 9, PATIENT, 9, ENCOUNTER, 9, CODE, 9, DESCRIPTION, 9, REASONCODE, 9, REASONDESCRIPTION, 10, ID, 10, PATIENT, 10, BILLABLEPERIOD, 10, ORGANIZATION, 10, ENCOUNTER, 10, DIAGNOSIS, 10, TOTAL
Question: What is the difference between the number of married patients and the number of single patients with diabetes?
Evidence: 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';
SQL: 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'
Database: car_retails
Tables: offices, employees, customers, orders, payments, productlines, products, orderdetails
Columns (table index, column name): -1, *, 0, officeCode, 0, city, 0, phone, 0, addressLine1, 0, addressLine2, 0, state, 0, country, 0, postalCode, 0, territory, 1, employeeNumber, 1, lastName, 1, firstName, 1, extension, 1, email, 1, officeCode, 1, reportsTo, 1, jobTitle, 2, customerNumber, 2, customerName, 2, contactLastName, 2, contactFirstName, 2, phone, 2, addressLine1, 2, addressLine2, 2, city, 2, state, 2, postalCode, 2, country, 2, salesRepEmployeeNumber, 2, creditLimit, 3, orderNumber, 3, orderDate, 3, requiredDate, 3, shippedDate, 3, status, 3, comments, 3, customerNumber, 4, customerNumber, 4, checkNumber, 4, paymentDate, 4, amount, 5, productLine, 5, textDescription, 5, htmlDescription, 5, image, 6, productCode, 6, productName, 6, productLine, 6, productScale, 6, productVendor, 6, productDescription, 6, quantityInStock, 6, buyPrice, 6, MSRP, 7, orderNumber, 7, productCode, 7, quantityOrdered, 7, priceEach, 7, orderLineNumber
Question: List the country and how many customers are there.
SQL: SELECT country, COUNT(customerNumber) FROM customers GROUP BY country
Database: car_retails
Tables: offices, employees, customers, orders, payments, productlines, products, orderdetails
Columns (table index, column name): -1, *, 0, officeCode, 0, city, 0, phone, 0, addressLine1, 0, addressLine2, 0, state, 0, country, 0, postalCode, 0, territory, 1, employeeNumber, 1, lastName, 1, firstName, 1, extension, 1, email, 1, officeCode, 1, reportsTo, 1, jobTitle, 2, customerNumber, 2, customerName, 2, contactLastName, 2, contactFirstName, 2, phone, 2, addressLine1, 2, addressLine2, 2, city, 2, state, 2, postalCode, 2, country, 2, salesRepEmployeeNumber, 2, creditLimit, 3, orderNumber, 3, orderDate, 3, requiredDate, 3, shippedDate, 3, status, 3, comments, 3, customerNumber, 4, customerNumber, 4, checkNumber, 4, paymentDate, 4, amount, 5, productLine, 5, textDescription, 5, htmlDescription, 5, image, 6, productCode, 6, productName, 6, productLine, 6, productScale, 6, productVendor, 6, productDescription, 6, quantityInStock, 6, buyPrice, 6, MSRP, 7, orderNumber, 7, productCode, 7, quantityOrdered, 7, priceEach, 7, orderLineNumber
Question: Which different vendor has the most amount of orders? Calculate the total estimated earnings.
Evidence: 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);
SQL: SELECT DISTINCT T1.productVendor, T1.MSRP - T1.buyPrice FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode GROUP BY T1.productVendor, T1.MSRP, T1.buyPrice ORDER BY COUNT(T2.quantityOrdered) DESC LIMIT 1
Database: car_retails
Tables: offices, employees, customers, orders, payments, productlines, products, orderdetails
Columns (table index, column name): -1, *, 0, officeCode, 0, city, 0, phone, 0, addressLine1, 0, addressLine2, 0, state, 0, country, 0, postalCode, 0, territory, 1, employeeNumber, 1, lastName, 1, firstName, 1, extension, 1, email, 1, officeCode, 1, reportsTo, 1, jobTitle, 2, customerNumber, 2, customerName, 2, contactLastName, 2, contactFirstName, 2, phone, 2, addressLine1, 2, addressLine2, 2, city, 2, state, 2, postalCode, 2, country, 2, salesRepEmployeeNumber, 2, creditLimit, 3, orderNumber, 3, orderDate, 3, requiredDate, 3, shippedDate, 3, status, 3, comments, 3, customerNumber, 4, customerNumber, 4, checkNumber, 4, paymentDate, 4, amount, 5, productLine, 5, textDescription, 5, htmlDescription, 5, image, 6, productCode, 6, productName, 6, productLine, 6, productScale, 6, productVendor, 6, productDescription, 6, quantityInStock, 6, buyPrice, 6, MSRP, 7, orderNumber, 7, productCode, 7, quantityOrdered, 7, priceEach, 7, orderLineNumber
Question: Who is the sales agent of the distinct customer who paid the highest amount in the year 2004?
SQL: SELECT DISTINCT T3.lastName, T3.firstName FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber INNER JOIN employees AS T3 ON T2.salesRepEmployeeNumber = T3.employeeNumber WHERE STRFTIME('%Y', T1.paymentDate) = '2004' ORDER BY T1.amount DESC LIMIT 1
Database: car_retails
Tables: offices, employees, customers, orders, payments, productlines, products, orderdetails
Columns (table index, column name): -1, *, 0, officeCode, 0, city, 0, phone, 0, addressLine1, 0, addressLine2, 0, state, 0, country, 0, postalCode, 0, territory, 1, employeeNumber, 1, lastName, 1, firstName, 1, extension, 1, email, 1, officeCode, 1, reportsTo, 1, jobTitle, 2, customerNumber, 2, customerName, 2, contactLastName, 2, contactFirstName, 2, phone, 2, addressLine1, 2, addressLine2, 2, city, 2, state, 2, postalCode, 2, country, 2, salesRepEmployeeNumber, 2, creditLimit, 3, orderNumber, 3, orderDate, 3, requiredDate, 3, shippedDate, 3, status, 3, comments, 3, customerNumber, 4, customerNumber, 4, checkNumber, 4, paymentDate, 4, amount, 5, productLine, 5, textDescription, 5, htmlDescription, 5, image, 6, productCode, 6, productName, 6, productLine, 6, productScale, 6, productVendor, 6, productDescription, 6, quantityInStock, 6, buyPrice, 6, MSRP, 7, orderNumber, 7, productCode, 7, quantityOrdered, 7, priceEach, 7, orderLineNumber
Question: What was the total price of the products shipped to Rovelli Gifts Distributors Ltd. between 1/1/2003 and 12/31/2003?
Evidence: Mini Gifts Distributors Ltd. Is the customer name; shippedDate between '2003-01-01' and '2003-12-31'; total price = MULTIPLY(quantityOrdered, priceEach);
SQL: SELECT T3.priceEach * T3.quantityOrdered 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 T1.customerName = 'Rovelli Gifts' AND T2.status = 'Shipped' AND STRFTIME('%Y', T2.shippedDate) = '2003'
Database: car_retails
Tables: offices, employees, customers, orders, payments, productlines, products, orderdetails
Columns (table index, column name): -1, *, 0, officeCode, 0, city, 0, phone, 0, addressLine1, 0, addressLine2, 0, state, 0, country, 0, postalCode, 0, territory, 1, employeeNumber, 1, lastName, 1, firstName, 1, extension, 1, email, 1, officeCode, 1, reportsTo, 1, jobTitle, 2, customerNumber, 2, customerName, 2, contactLastName, 2, contactFirstName, 2, phone, 2, addressLine1, 2, addressLine2, 2, city, 2, state, 2, postalCode, 2, country, 2, salesRepEmployeeNumber, 2, creditLimit, 3, orderNumber, 3, orderDate, 3, requiredDate, 3, shippedDate, 3, status, 3, comments, 3, customerNumber, 4, customerNumber, 4, checkNumber, 4, paymentDate, 4, amount, 5, productLine, 5, textDescription, 5, htmlDescription, 5, image, 6, productCode, 6, productName, 6, productLine, 6, productScale, 6, productVendor, 6, productDescription, 6, quantityInStock, 6, buyPrice, 6, MSRP, 7, orderNumber, 7, productCode, 7, quantityOrdered, 7, priceEach, 7, orderLineNumber
Question: How many employees are there in Sydney?
Evidence: sales agent and sales representative are synonyms; Sydney is a city;
SQL: SELECT COUNT(employeeNumber) FROM employees WHERE officeCode = ( SELECT officeCode FROM offices WHERE city = 'Sydney' )
Database: car_retails
Tables: offices, employees, customers, orders, payments, productlines, products, orderdetails
Columns (table index, column name): -1, *, 0, officeCode, 0, city, 0, phone, 0, addressLine1, 0, addressLine2, 0, state, 0, country, 0, postalCode, 0, territory, 1, employeeNumber, 1, lastName, 1, firstName, 1, extension, 1, email, 1, officeCode, 1, reportsTo, 1, jobTitle, 2, customerNumber, 2, customerName, 2, contactLastName, 2, contactFirstName, 2, phone, 2, addressLine1, 2, addressLine2, 2, city, 2, state, 2, postalCode, 2, country, 2, salesRepEmployeeNumber, 2, creditLimit, 3, orderNumber, 3, orderDate, 3, requiredDate, 3, shippedDate, 3, status, 3, comments, 3, customerNumber, 4, customerNumber, 4, checkNumber, 4, paymentDate, 4, amount, 5, productLine, 5, textDescription, 5, htmlDescription, 5, image, 6, productCode, 6, productName, 6, productLine, 6, productScale, 6, productVendor, 6, productDescription, 6, quantityInStock, 6, buyPrice, 6, MSRP, 7, orderNumber, 7, productCode, 7, quantityOrdered, 7, priceEach, 7, orderLineNumber
Question: Which sales representatives in New York city whose leader is Anthony Bow with the employee number is 1143? Indicate their employee numbers.
Evidence: reportsTO' is the leader of the 'employeeNumber';
SQL: 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'
Database: car_retails
Tables: offices, employees, customers, orders, payments, productlines, products, orderdetails
Columns (table index, column name): -1, *, 0, officeCode, 0, city, 0, phone, 0, addressLine1, 0, addressLine2, 0, state, 0, country, 0, postalCode, 0, territory, 1, employeeNumber, 1, lastName, 1, firstName, 1, extension, 1, email, 1, officeCode, 1, reportsTo, 1, jobTitle, 2, customerNumber, 2, customerName, 2, contactLastName, 2, contactFirstName, 2, phone, 2, addressLine1, 2, addressLine2, 2, city, 2, state, 2, postalCode, 2, country, 2, salesRepEmployeeNumber, 2, creditLimit, 3, orderNumber, 3, orderDate, 3, requiredDate, 3, shippedDate, 3, status, 3, comments, 3, customerNumber, 4, customerNumber, 4, checkNumber, 4, paymentDate, 4, amount, 5, productLine, 5, textDescription, 5, htmlDescription, 5, image, 6, productCode, 6, productName, 6, productLine, 6, productScale, 6, productVendor, 6, productDescription, 6, quantityInStock, 6, buyPrice, 6, MSRP, 7, orderNumber, 7, productCode, 7, quantityOrdered, 7, priceEach, 7, orderLineNumber
Question: What is the average, highest and lowest annual payments collected between 1/1/2003 to 12/31/2005?
Evidence: paymentDate BETWEEN '2003-01-01' AND '2005-12-31'; average annual payments = DIVIDE(SUM(amount), 3);
SQL: 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'
Database: car_retails
Tables: offices, employees, customers, orders, payments, productlines, products, orderdetails
Columns (table index, column name): -1, *, 0, officeCode, 0, city, 0, phone, 0, addressLine1, 0, addressLine2, 0, state, 0, country, 0, postalCode, 0, territory, 1, employeeNumber, 1, lastName, 1, firstName, 1, extension, 1, email, 1, officeCode, 1, reportsTo, 1, jobTitle, 2, customerNumber, 2, customerName, 2, contactLastName, 2, contactFirstName, 2, phone, 2, addressLine1, 2, addressLine2, 2, city, 2, state, 2, postalCode, 2, country, 2, salesRepEmployeeNumber, 2, creditLimit, 3, orderNumber, 3, orderDate, 3, requiredDate, 3, shippedDate, 3, status, 3, comments, 3, customerNumber, 4, customerNumber, 4, checkNumber, 4, paymentDate, 4, amount, 5, productLine, 5, textDescription, 5, htmlDescription, 5, image, 6, productCode, 6, productName, 6, productLine, 6, productScale, 6, productVendor, 6, productDescription, 6, quantityInStock, 6, buyPrice, 6, MSRP, 7, orderNumber, 7, productCode, 7, quantityOrdered, 7, priceEach, 7, orderLineNumber
Question: Which countries do the top 5 highest paying customers in a single payment come from? Indicate their entire address.
Evidence: highest paying customer refers to MAX(amount); entire address = addressLine1+addressLine2;
SQL: SELECT DISTINCT T2.country, T2.addressLine1, T2.addressLine2 FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber ORDER BY T1.amount DESC LIMIT 5
Database: car_retails
Tables: offices, employees, customers, orders, payments, productlines, products, orderdetails
Columns (table index, column name): -1, *, 0, officeCode, 0, city, 0, phone, 0, addressLine1, 0, addressLine2, 0, state, 0, country, 0, postalCode, 0, territory, 1, employeeNumber, 1, lastName, 1, firstName, 1, extension, 1, email, 1, officeCode, 1, reportsTo, 1, jobTitle, 2, customerNumber, 2, customerName, 2, contactLastName, 2, contactFirstName, 2, phone, 2, addressLine1, 2, addressLine2, 2, city, 2, state, 2, postalCode, 2, country, 2, salesRepEmployeeNumber, 2, creditLimit, 3, orderNumber, 3, orderDate, 3, requiredDate, 3, shippedDate, 3, status, 3, comments, 3, customerNumber, 4, customerNumber, 4, checkNumber, 4, paymentDate, 4, amount, 5, productLine, 5, textDescription, 5, htmlDescription, 5, image, 6, productCode, 6, productName, 6, productLine, 6, productScale, 6, productVendor, 6, productDescription, 6, quantityInStock, 6, buyPrice, 6, MSRP, 7, orderNumber, 7, productCode, 7, quantityOrdered, 7, priceEach, 7, orderLineNumber
Question: How many checks were issued by Euro+ Shopping Channel in the year 2004?
Evidence: Euro+ Shopping Channel is a customer name; year(paymentDate) = '2004';
SQL: SELECT COUNT(T1.checkNumber) FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE customerName = 'Euro+ Shopping Channel' AND STRFTIME('%Y', T1.paymentDate) = '2004'
Database: car_retails
Tables: offices, employees, customers, orders, payments, productlines, products, orderdetails
Columns (table index, column name): -1, *, 0, officeCode, 0, city, 0, phone, 0, addressLine1, 0, addressLine2, 0, state, 0, country, 0, postalCode, 0, territory, 1, employeeNumber, 1, lastName, 1, firstName, 1, extension, 1, email, 1, officeCode, 1, reportsTo, 1, jobTitle, 2, customerNumber, 2, customerName, 2, contactLastName, 2, contactFirstName, 2, phone, 2, addressLine1, 2, addressLine2, 2, city, 2, state, 2, postalCode, 2, country, 2, salesRepEmployeeNumber, 2, creditLimit, 3, orderNumber, 3, orderDate, 3, requiredDate, 3, shippedDate, 3, status, 3, comments, 3, customerNumber, 4, customerNumber, 4, checkNumber, 4, paymentDate, 4, amount, 5, productLine, 5, textDescription, 5, htmlDescription, 5, image, 6, productCode, 6, productName, 6, productLine, 6, productScale, 6, productVendor, 6, productDescription, 6, quantityInStock, 6, buyPrice, 6, MSRP, 7, orderNumber, 7, productCode, 7, quantityOrdered, 7, priceEach, 7, orderLineNumber
Question: Of all the classic cars, with a product scale of 1:18, which product is the most ordered product by customers?
Evidence: classic car is a product line; most ordered product refers to MAX(quantityOrdered);
SQL: 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
Database: car_retails
Tables: offices, employees, customers, orders, payments, productlines, products, orderdetails
Columns (table index, column name): -1, *, 0, officeCode, 0, city, 0, phone, 0, addressLine1, 0, addressLine2, 0, state, 0, country, 0, postalCode, 0, territory, 1, employeeNumber, 1, lastName, 1, firstName, 1, extension, 1, email, 1, officeCode, 1, reportsTo, 1, jobTitle, 2, customerNumber, 2, customerName, 2, contactLastName, 2, contactFirstName, 2, phone, 2, addressLine1, 2, addressLine2, 2, city, 2, state, 2, postalCode, 2, country, 2, salesRepEmployeeNumber, 2, creditLimit, 3, orderNumber, 3, orderDate, 3, requiredDate, 3, shippedDate, 3, status, 3, comments, 3, customerNumber, 4, customerNumber, 4, checkNumber, 4, paymentDate, 4, amount, 5, productLine, 5, textDescription, 5, htmlDescription, 5, image, 6, productCode, 6, productName, 6, productLine, 6, productScale, 6, productVendor, 6, productDescription, 6, quantityInStock, 6, buyPrice, 6, MSRP, 7, orderNumber, 7, productCode, 7, quantityOrdered, 7, priceEach, 7, orderLineNumber
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?
Evidence: creditLimit < = 100000; total payment amount refers to amount; highest total payment amount refers to MAX(amount); year(paymentDate) = '2004';
SQL: SELECT ( SELECT COUNT(customerNumber) FROM customers WHERE creditLimit <= 100000 AND customerNumber IN ( SELECT customerNumber FROM payments WHERE STRFTIME('%Y', paymentDate) = '2004' ) ), T1.customerName FROM customers AS T1 INNER JOIN payments AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.creditLimit <= 100000 AND STRFTIME('%Y', T2.paymentDate) = '2004' GROUP BY T1.customerNumber, T1.customerName ORDER BY SUM(T2.amount) DESC LIMIT 1
Database: car_retails
Tables: offices, employees, customers, orders, payments, productlines, products, orderdetails
Columns (table index, column name): -1, *, 0, officeCode, 0, city, 0, phone, 0, addressLine1, 0, addressLine2, 0, state, 0, country, 0, postalCode, 0, territory, 1, employeeNumber, 1, lastName, 1, firstName, 1, extension, 1, email, 1, officeCode, 1, reportsTo, 1, jobTitle, 2, customerNumber, 2, customerName, 2, contactLastName, 2, contactFirstName, 2, phone, 2, addressLine1, 2, addressLine2, 2, city, 2, state, 2, postalCode, 2, country, 2, salesRepEmployeeNumber, 2, creditLimit, 3, orderNumber, 3, orderDate, 3, requiredDate, 3, shippedDate, 3, status, 3, comments, 3, customerNumber, 4, customerNumber, 4, checkNumber, 4, paymentDate, 4, amount, 5, productLine, 5, textDescription, 5, htmlDescription, 5, image, 6, productCode, 6, productName, 6, productLine, 6, productScale, 6, productVendor, 6, productDescription, 6, quantityInStock, 6, buyPrice, 6, MSRP, 7, orderNumber, 7, productCode, 7, quantityOrdered, 7, priceEach, 7, orderLineNumber
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.
Evidence: Tokyo is a city; 'reportsTO' is the leader of the 'employeeNumber'; highest payment refers to MAX(amount); total amount of payments = SUM(amount);
SQL: SELECT T2.customerName, T2.contactFirstName, T2.contactLastName, SUM(T3.amount) FROM employees AS T1 INNER JOIN customers AS T2 ON T2.salesRepEmployeeNumber = T1.employeeNumber INNER JOIN payments AS T3 ON T2.customerNumber = T3.customerNumber INNER JOIN offices AS T4 ON T1.officeCode = T4.officeCode WHERE T4.city = 'Tokyo' AND T1.reportsTo = 1056 GROUP BY T2.customerName, T2.contactFirstName, T2.contactLastName ORDER BY amount DESC LIMIT 1