input
stringlengths 236
16.9k
| output
stringlengths 19
805
|
---|---|
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- How many customers with a canceled shipment have a credit limit greater than 115,000?
| 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; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- 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; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- To whom does the employee have to inform that is the sales representative of the French customer?
| SELECT T1.reportsTo FROM employees AS T1 INNER JOIN customers AS T2 ON T1.employeeNumber = T2.salesRepEmployeeNumber WHERE T2.country = 'France'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- What is the full address of the customer who commented that DHL be used for the order that was shipped on April 4, 2005?
| 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'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- 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?
| 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'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- What is the full address of the office where 4 people work and one of them is Sales Representation?
| SELECT T1.addressLine1, T1.addressLine2 FROM customers AS T1 INNER JOIN employees AS T2 ON T1.salesRepEmployeeNumber = T2.employeeNumber WHERE T2.jobTitle = 'Sales Rep'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- 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"?
| 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%'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Of the clients whose businesses are located in the city of Boston, calculate which of them has a higher average amount of payment.
| 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; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Calculate the total quantity ordered for 18th Century Vintage Horse Carriage and the average price.
| 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'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- How many kinds of products did order No. 10252 contain?
| SELECT COUNT(t.productCode) FROM orderdetails t WHERE t.orderNumber = '10252'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Who is the sales representative that made the order which was sent to 25 Maiden Lane, Floor No. 4?
| 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'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Where's Foon Yue Tseng's office located at? Give the detailed address.
| 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'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Compared with the orders happened on 2005-04-08 and two days later, which day's order had a higher value?
| SELECT T2.orderDate FROM orderdetails AS T1 INNER JOIN orders AS T2 ON T1.orderNumber = T2.orderNumber WHERE STRFTIME('%Y-%m-%d', T2.orderDate) = '2005-04-08' OR STRFTIME('%Y-%m-%d', T2.orderDate) = '2005-04-10' ORDER BY T1.quantityOrdered * T1.priceEach DESC LIMIT 1; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- How many products with the highest expected profits were sold in total?
| 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; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- How much did Petit Auto pay on 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'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- What was the contact name for the check "NR157385"?
| SELECT t2.contactFirstName, t2.contactLastName FROM payments AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t1.checkNumber = 'NR157385'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- 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'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Where was the order No. 10383 shipped to? Show me the address.
| SELECT t2.addressLine1, t2.addressLine2 FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t1.orderNumber = '10383'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- 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'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- 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?
| SELECT t2.email FROM customers AS t1 INNER JOIN employees AS t2 ON t1.salesRepEmployeeNumber = t2.employeeNumber WHERE t1.customerName = 'Dragon Souveniers, Ltd.'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- How many French customers does Gerard Hernandez take care of?
| 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'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- What was the latest order that customer No.114 made? Give the name of the product.
| 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; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- For the product No. S18_3482 in the Order No.10108, how much discount did the customer have?
| 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'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- To whom does Steve Patterson report? Please give his or her full name.
| 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'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- How do I contact the President of the company?
| SELECT t.email FROM employees t WHERE t.jobTitle = 'President'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Who is the sales representitive of Muscle Machine Inc? Please give the employee's full name.
| 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'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- 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?
| SELECT t2.email FROM customers AS t1 INNER JOIN employees AS t2 ON t1.salesRepEmployeeNumber = t2.employeeNumber WHERE t1.customerName = 'Muscle Machine Inc'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Please list all the customers that have Steve Patterson as their sales representitive.
| 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'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- How many customers have an employee who reports to William Patterson as their sales representitive?
| 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'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- 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; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- How many sales representitives are based in the offices in the 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'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Where can I find the office of the President of the company?
| SELECT t2.addressLine1, t2.addressLine2 FROM employees AS t1 INNER JOIN offices AS t2 ON t1.officeCode = t2.officeCode WHERE t1.jobTitle = 'President'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- What's the postal code of the office the VP Sales is at?
| SELECT t2.postalCode FROM employees AS t1 INNER JOIN offices AS t2 ON t1.officeCode = t2.officeCode WHERE t1.jobTitle = 'VP Sales'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- What is the total price of the order made by Cruz & Sons Co. on 2003/3/3?
| SELECT SUM(t1.priceEach * t1.quantityOrdered) FROM orderdetails AS t1 INNER JOIN orders AS t2 ON t1.orderNumber = t2.orderNumber INNER JOIN customers AS t3 ON t2.customerNumber = t3.customerNumber WHERE t3.customerName = 'Cruz & Sons Co.' AND t2.orderDate = '2003-03-03'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Which product did Cruz & Sons Co. order on 2003/3/3?
| SELECT t4.productName FROM orderdetails AS t1 INNER JOIN orders AS t2 ON t1.orderNumber = t2.orderNumber INNER JOIN customers AS t3 ON t2.customerNumber = t3.customerNumber INNER JOIN products AS t4 ON t1.productCode = t4.productCode WHERE t3.customerName = 'Cruz & Sons Co.' AND t2.orderDate = '2003-03-03'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Which product did Cruz & Sons Co. ask for the biggest amount in a single order?
| SELECT t4.productName FROM orderdetails AS t1 INNER JOIN orders AS t2 ON t1.orderNumber = t2.orderNumber INNER JOIN customers AS t3 ON t2.customerNumber = t3.customerNumber INNER JOIN products AS t4 ON t1.productCode = t4.productCode WHERE t3.customerName = 'Cruz & Sons Co.' ORDER BY t1.priceEach * t1.quantityOrdered DESC LIMIT 1; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- When were the products ordered by Cruz & Sons Co. on 2003-03-03 shipped?
| SELECT t1.shippedDate FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t2.customerName = 'Cruz & Sons Co.' AND t1.orderDate = '2003-03-03'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- What is the amount of customers of 1957 Chevy Pickup by customers in a month?
| SELECT COUNT(T2.customerNumber) FROM orderdetails AS T1 INNER JOIN orders AS T2 ON T1.orderNumber = T2.orderNumber WHERE T1.productCode IN ( SELECT productCode FROM products WHERE productName = '1957 Chevy Pickup' ); |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Name the product from the 'Classic Cars' production line that has the greatest expected profit.
| SELECT t.productName, t.MSRP - t.buyPrice FROM products AS t WHERE t.productLine = 'Classic Cars' ORDER BY t.MSRP - t.buyPrice DESC LIMIT 1; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- List all the name of customers who have orders that are still processing.
| SELECT t2.customerName FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t1.status = 'In Process'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Among all orders shipped, calculate the percentage of orders shipped at least 3 days before the required date.
| SELECT COUNT(CASE WHEN JULIANDAY(t1.shippeddate) - JULIANDAY(t1.requireddate) > 3 THEN T1.customerNumber ELSE NULL END) FROM orders AS T1 INNER JOIN orderdetails AS T2 ON T1.orderNumber = T2.orderNumber WHERE T1.status = 'Shipped'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Find the customer who made the highest payment in 2005.
| SELECT t2.customerName FROM payments AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE STRFTIME('%Y', t1.paymentDate) = '2005' GROUP BY t2.customerNumber, t2.customerName ORDER BY SUM(t1.amount) DESC LIMIT 1; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Which is the most ordered quantity product? What is its expected profit margin per piece?
| SELECT productName, MSRP - buyPrice FROM products WHERE productCode = ( SELECT productCode FROM orderdetails ORDER BY quantityOrdered DESC LIMIT 1 ); |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- For the order has the most product ordered, name the customer who placed the order.
| SELECT T2.firstName, T2.lastName FROM offices AS T1 INNER JOIN employees AS T2 ON T1.officeCode = T2.officeCode WHERE T2.employeeNumber = ( SELECT MAX(employeeNumber) FROM employees ); |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- List all customer names with orders that are disputed.
| SELECT t3.firstName, t3.lastName FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber INNER JOIN employees AS t3 ON t2.salesRepEmployeeNumber = t3.employeeNumber WHERE t1.status = 'Disputed'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- What is the percentage of employees are in Paris office?
| SELECT CAST(COUNT(CASE WHEN t1.city = 'Paris' THEN t2.employeeNumber ELSE NULL END) AS REAL) * 100 / COUNT(t2.employeeNumber) FROM offices AS t1 INNER JOIN employees AS t2 ON t1.officeCode = t2.officeCode; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Name the Sales Manager of Europe, Middle East, and Africa region. In which office does he/she report to?
| SELECT t2.firstName, t2.lastName FROM offices AS t1 INNER JOIN employees AS t2 ON t1.officeCode = t2.officeCode WHERE t2.jobTitle = 'Sale Manager (EMEA)'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- List the name of employees in Japan office and who are they reporting to.
| SELECT t2.firstName, t2.lastName, t2.reportsTo FROM offices AS t1 INNER JOIN employees AS t2 ON t1.officeCode = t2.officeCode WHERE t1.country = 'Japan'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Which customer ordered 1939 'Chevrolet Deluxe Coupe' at the highest price?
| SELECT t4.customerName 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.productName = '1939 Chevrolet Deluxe Coupe' ORDER BY t2.priceEach DESC LIMIT 1; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- What is the percentage of the payment amount in 2004 was made by Atelier graphique?
| SELECT SUM(CASE WHEN t1.customerName = 'Atelier graphique' THEN t2.amount ELSE 0 END) * 100 / SUM(t2.amount) FROM customers AS t1 INNER JOIN payments AS t2 ON t1.customerNumber = t2.customerNumber WHERE STRFTIME('%Y', t2.paymentDate) = '2004'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Calculate the actual profit for order number 10100.
| SELECT SUM((t1.priceEach - t2.buyPrice) * t1.quantityOrdered) FROM orderdetails AS t1 INNER JOIN products AS t2 ON t1.productCode = t2.productCode WHERE t1.orderNumber = '10100'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- How much did customer 103 pay in total?
| SELECT SUM(t.amount) FROM payments t WHERE t.customerNumber = '103'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- What is the total price of the order 10100?
| SELECT SUM(t.priceEach * t.quantityOrdered) FROM orderdetails t WHERE t.orderNumber = '10100'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Please list the top three product names with the highest unit price.
| SELECT t1.productName FROM products AS t1 INNER JOIN orderdetails AS t2 ON t1.productCode = t2.productCode ORDER BY t2.priceEach DESC LIMIT 3; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Among the customers of empolyee 1370, who has the highest credit limit?Please list the full name of the contact person.
| SELECT t2.contactFirstName, t2.contactLastName FROM employees AS t1 INNER JOIN customers AS t2 ON t1.employeeNumber = t2.salesRepEmployeeNumber WHERE t1.employeeNumber = '1370' ORDER BY t2.creditLimit DESC LIMIT 1; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- How many 2003 Harley-Davidson Eagle Drag Bikes were ordered?
| SELECT SUM(t2.quantityOrdered) FROM products AS t1 INNER JOIN orderdetails AS t2 ON t1.productCode = t2.productCode WHERE t1.productName = '2003 Harley-Davidson Eagle Drag Bike'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- When was the product with the highest unit price shipped?
| SELECT t1.shippedDate FROM orders AS t1 INNER JOIN orderdetails AS t2 ON t1.orderNumber = t2.orderNumber ORDER BY t2.priceEach DESC LIMIT 1; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- How many motorcycles have been ordered in 2004?
| SELECT SUM(t2.quantityOrdered) FROM orders AS t1 INNER JOIN orderdetails AS t2 ON t1.orderNumber = t2.orderNumber INNER JOIN products AS t3 ON t2.productCode = t3.productCode WHERE t3.productLine = 'motorcycles' AND STRFTIME('%Y', t1.orderDate) = '2004'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Please list the order number of the customer whose credit card has a limit of 45300.
| SELECT t1.orderNumber FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t2.creditLimit = 45300; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- For Which order was the most profitable, please list the customer name of the order and the profit of the order.
| SELECT t3.customerName, (t1.priceEach - t4.buyPrice) * t1.quantityOrdered FROM orderdetails AS t1 INNER JOIN orders AS t2 ON t1.orderNumber = t2.orderNumber INNER JOIN customers AS t3 ON t2.customerNumber = t3.customerNumber INNER JOIN products AS t4 ON t1.productCode = t4.productCode GROUP BY t3.customerName, t1.priceEach, t4.buyPrice, t1.quantityOrdered ORDER BY (t1.priceEach - t4.buyPrice) * t1.quantityOrdered DESC LIMIT 1; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- How many transactions payment made by customer that is lower than 10000. Group the result by year.
| SELECT STRFTIME('%Y', t1.paymentDate), COUNT(t1.customerNumber) FROM payments AS t1 WHERE t1.amount < 10000 GROUP BY STRFTIME('%Y', t1.paymentDate); |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- List out 3 best seller products during year 2003 with their total quantity sold during 2003.
| SELECT t3.productName, SUM(t2.quantityOrdered) FROM orders AS t1 INNER JOIN orderdetails AS t2 ON t1.orderNumber = t2.orderNumber INNER JOIN products AS t3 ON t2.productCode = t3.productCode WHERE STRFTIME('%Y', t1.orderDate) = '2003' GROUP BY t3.productName ORDER BY SUM(t2.quantityOrdered) DESC LIMIT 3; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- List out sale rep that has sold 1969 Harley Davidson Ultimate Chopper. List out their names and quantity sold throughout the year.
| SELECT t5.firstName, t5.lastName, SUM(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 INNER JOIN customers AS t4 ON t3.customerNumber = t4.customerNumber INNER JOIN employees AS t5 ON t4.salesRepEmployeeNumber = t5.employeeNumber WHERE t1.productName = '1969 Harley Davidson Ultimate Chopper' GROUP BY t5.lastName, t5.firstName; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Who are the sales representatives in New York City? List their full names.
| SELECT t1.lastName, t1.firstName FROM employees AS t1 INNER JOIN offices AS t2 ON t1.officeCode = t2.officeCode WHERE t2.city = 'NYC' AND t1.jobTitle = 'Sales Rep'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Identify the customer and list down the country with the check number GG31455.
| SELECT t2.customerName, t2.country FROM payments AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t1.checkNumber = 'GG31455'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- How many 2001 Ferrari Enzo were ordered?
| SELECT SUM(t1.orderNumber) FROM orderdetails AS t1 INNER JOIN products AS t2 ON t1.productCode = t2.productCode WHERE t2.productName = '2001 Ferrari Enzo'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Which 5 products has the lowest amount of orders? List the product names.
| SELECT t2.productName FROM orderdetails AS t1 INNER JOIN products AS t2 ON t1.productCode = t2.productCode GROUP BY t2.productName ORDER BY SUM(t1.quantityOrdered) ASC LIMIT 5; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- List down the customer names with a disputed order status.
| SELECT t1.customerName FROM customers AS t1 INNER JOIN orders AS t2 ON t1.customerNumber = t2.customerNumber WHERE t2.status = 'Disputed'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- How many countries from the USA have an In Process order status?
| SELECT COUNT(t2.orderNumber) FROM customers AS t1 INNER JOIN orders AS t2 ON t1.customerNumber = t2.customerNumber WHERE t2.status = 'On Hold' AND t1.country = 'USA'; |
-- Database schema
| offices : officeCode [ TEXT ] primary_key , city [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , state [ TEXT ] , country [ TEXT ] , postalCode [ TEXT ] , territory [ TEXT ] | employees : employeeNumber [ INTEGER ] primary_key , lastName [ TEXT ] , firstName [ TEXT ] , extension [ TEXT ] , email [ TEXT ] , officeCode [ TEXT ] employees.officeCode = offices.officeCode , reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber , jobTitle [ TEXT ] | customers : customerNumber [ INTEGER ] primary_key , customerName [ TEXT ] , contactLastName [ TEXT ] , contactFirstName [ TEXT ] , phone [ TEXT ] , addressLine1 [ TEXT ] , addressLine2 [ TEXT ] , city [ TEXT ] , state [ TEXT ] , postalCode [ TEXT ] , country [ TEXT ] , salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber , creditLimit [ REAL ] | orders : orderNumber [ INTEGER ] primary_key , orderDate [ DATE ] , requiredDate [ DATE ] , shippedDate [ DATE ] , status [ TEXT ] , comments [ TEXT ] , customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber | payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber , checkNumber [ TEXT ] , paymentDate [ DATE ] , amount [ REAL ] | productlines : productLine [ TEXT ] primary_key , textDescription [ TEXT ] , htmlDescription [ TEXT ] , image [ BLOB ] | products : productCode [ TEXT ] primary_key , productName [ TEXT ] , productLine [ TEXT ] products.productLine = productlines.productLine , productScale [ TEXT ] , productVendor [ TEXT ] , productDescription [ TEXT ] , quantityInStock [ INTEGER ] , buyPrice [ REAL ] , MSRP [ REAL ] | orderdetails : orderNumber [ INTEGER ] , productCode [ TEXT ] , quantityOrdered [ INTEGER ] , priceEach [ REAL ] , orderLineNumber [ INTEGER ] |
-- -- Calculate the total price of shipped orders belonging to Land of Toys Inc. under the classic car line of products.
| SELECT SUM(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 INNER JOIN products AS t4 ON t3.productCode = t4.productCode WHERE t4.productLine = 'Classic Cars' AND t1.customerName = 'Land of Toys Inc.' AND t2.status = 'Shipped'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- How many restaurants have not obtained a minimum of 3 in their reviews?
| SELECT COUNT(id_restaurant) FROM generalinfo WHERE review < 3; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- What types of food are served at the 4 top-reviewed restaurants?
| SELECT food_type FROM generalinfo WHERE review = ( SELECT MAX(review) FROM generalinfo ) LIMIT 4; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- How many restaurants in the city of Richmond serve Mediterranean food?
| SELECT COUNT(id_restaurant) FROM generalinfo WHERE food_type = 'mediterranean' AND city = 'richmond'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- List all the cities in Sonoma County.
| SELECT city FROM geographic WHERE county = 'sonoma county'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- What counties are not in the Bay Area Region?
| SELECT DISTINCT county FROM geographic WHERE region != 'bay area'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- List all cities in the Northern California Region.
| SELECT city FROM geographic WHERE region = 'northern california'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- List by its ID number all restaurants on 11th Street in Oakland.
| SELECT id_restaurant FROM location WHERE city = 'oakland' AND street_name = '11th street'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- How many restaurants can we find at number 871 on its street?
| SELECT COUNT(id_restaurant) FROM location WHERE street_num = 871; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- At what numbers on 9th Avenue of San Francisco there are restaurants?
| SELECT id_restaurant FROM location WHERE City = 'san francisco' AND street_name = '9th avenue'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- What type of food is there in the restaurants on Adeline Street in Berkeley city?
| SELECT T1.food_type FROM generalinfo AS T1 INNER JOIN location AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T2.street_name = 'adeline st' AND T2.city = 'berkeley'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- In which regions are there no African food restaurants?
| SELECT DISTINCT T2.region FROM generalinfo AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city WHERE T1.food_type != 'african'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- In which counties are there A&W Root Beer Restaurants?
| SELECT DISTINCT T2.county FROM generalinfo AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city WHERE T1.label = 'a & w root beer'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- Indicate street and number of the Adelitas Taqueria Restaurants.
| SELECT T1.street_name, T1.street_num FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T2.label = 'adelitas taqueria'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- What type of food is served at the restaurant located at 3140, Alpine Road at San Mateo County?
| SELECT T2.food_type FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant INNER JOIN geographic AS T3 ON T2.city = T3.city WHERE T3.County = 'san mateo county' AND T1.street_name = 'alpine rd' AND T1.street_num = 3140; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- In which streets of the city of San Francisco are there restaurants that serve seafood?
| SELECT T1.street_name FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T1.city = 'san francisco' AND T2.food_type = 'seafood' AND street_name IS NOT NULL; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- List all counties where there is no Bakers Square Restaurant & Pie Shop.
| SELECT DISTINCT T2.county FROM generalinfo AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city WHERE T1.label != 'bakers square restaurant & pie shop'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- In how many counties is there a street called Appian Way?
| SELECT COUNT(DISTINCT T2.county) FROM location AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city WHERE T1.street_name = 'appian way'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- What is the rating of each restaurant reviews on Atlantic Ave?
| SELECT T1.review FROM generalinfo AS T1 INNER JOIN location AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T2.street_name = 'atlantic ave'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- Identify all restaurants in Contra Costa County by id.
| SELECT T1.id_restaurant FROM location AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city WHERE T2.county = 'contra costa county'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- Identify all the restaurants in Yolo County by their label.
| SELECT T1.id_restaurant, T1.label FROM generalinfo AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city WHERE T2.county = 'yolo county'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- What restaurant on Drive Street in San Rafael doesn't serve American food?
| SELECT T1.label FROM generalinfo AS T1 INNER JOIN location AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T2.street_name = 'drive' AND T1.food_type != 'american' AND T2.city = 'san rafael'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- On which streets in the city of San Francisco are there restaurants with a review of 1.7?
| SELECT T2.street_name FROM generalinfo AS T1 INNER JOIN location AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T1.city = 'san francisco' AND T1.review = 1.7; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- Which restaurant on the street Alameda de las Pulgas in the city of Menlo Park is the worst rated?
| SELECT T2.label FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T1.street_name = 'avenida de las pulgas' AND T2.city = 'menlo park' ORDER BY review LIMIT 1; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- On what street in Tuolumne County is Good Heavens restaurant located?
| SELECT T1.street_name FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant INNER JOIN geographic AS T3 ON T2.city = T3.city WHERE T2.label = 'good heavens' AND T3.county = 'tuolumne county'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- Indicate the street numbers where Aux Delices Vietnamese Restaurant are located.
| SELECT DISTINCT T1.street_num FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T2.label = 'aux delices vietnamese restaurant'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- Identify all the restaurants in Marin County by their id.
| SELECT T1.id_restaurant FROM generalinfo AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city WHERE T2.county = 'marin county'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- In which regions are there no pizza restaurants?
| SELECT DISTINCT T2.region FROM generalinfo AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city WHERE T1.food_type = 'pizza' AND T2.region != 'unknown'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- Calculate the average rating of reviews for restaurants in Santa Cruz County.
| SELECT AVG(T2.review) FROM geographic AS T1 INNER JOIN generalinfo AS T2 ON T1.city = T2.city WHERE T1.county = 'santa cruz county'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- What percentage of restaurants in Monterey County have Mexican food?
| SELECT CAST(SUM(IIF(T2.food_type = 'mexican', 1, 0)) AS REAL) * 100 / COUNT(T2.id_restaurant) FROM geographic AS T1 INNER JOIN generalinfo AS T2 ON T1.city = T2.city WHERE T1.county = 'monterey county'; |
-- Database schema
| geographic : city [ TEXT ] primary_key , county [ TEXT ] , region [ TEXT ] | generalinfo : id_restaurant [ INTEGER ] primary_key , label [ TEXT ] , food_type [ TEXT ] , city [ TEXT ] generalinfo.city = geographic.city , review [ REAL ] | location : id_restaurant [ INTEGER ] primary_key location.id_restaurant = generalinfo.id_restaurant , street_num [ INTEGER ] , street_name [ TEXT ] , city [ TEXT ] location.city = geographic.city |
-- -- What percentage of streets named 11th Street are in Alameda County?
| SELECT CAST(SUM(IIF(T1.street_name = '11th st', 1, 0)) AS REAL) * 100 / COUNT(T1.id_restaurant) FROM location AS T1 INNER JOIN geographic AS T2 ON T1.city = T2.city WHERE T2.County = 'alameda county'; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.