aherntech/sparc huggingface dataset:
Database: cre_Doc_Control_Systems
Question sequence:
Show me the document with id 2.
What about the document status code of document with id 1?
What is the document status description for this document?
SQL query sequence:
SELECT * FROM Documents WHERE document_id = 2;
SELECT Ref_Document_Status.document_status_code FROM Ref_Document_Status JOIN Documents ON Documents.document_status_code = Ref_Document_Status.document_status_code WHERE Documents.document_id = 1;
SELECT Ref_Document_Status.document_status_description FROM Ref_Document_Status JOIN Documents ON Documents.document_status_code = Ref_Document_Status.document_status_code WHERE Documents.document_id = 1;
Final question: What is the document status description of the document with id 1?
Final SQL: SELECT Ref_Document_Status.document_status_description FROM Ref_Document_Status JOIN Documents ON Documents.document_status_code = Ref_Document_Status.document_status_code WHERE Documents.document_id = 1;
Database: cre_Doc_Control_Systems
Question sequence:
Show me all the information about the documents.
List all the documents with status code working?
How about the status code done?
How many are there?
SQL query sequence:
SELECT * FROM Documents
SELECT * FROM Documents WHERE document_status_code = "working";
SELECT * FROM Documents WHERE document_status_code = "done";
SELECT count(*) FROM Documents WHERE document_status_code = "done";
Final question: How many documents have the status code done?
Final SQL: SELECT count(*) FROM Documents WHERE document_status_code = "done";
Database: cre_Doc_Control_Systems
Question sequence:
Show me document with id 1.
What about the document status description of document with id 2?
What is the document status code of this document?
SQL query sequence:
SELECT * FROM Documents WHERE document_id = 1;
SELECT Ref_Document_Status.document_status_description FROM Ref_Document_Status JOIN Documents ON Documents.document_status_code = Ref_Document_Status.document_status_code WHERE Documents.document_id = 2;
SELECT document_type_code FROM Documents WHERE document_id = 2;
Final question: List the document type code for the document with the id 2.
Final SQL: SELECT document_type_code FROM Documents WHERE document_id = 2;
Database: cre_Doc_Control_Systems
Question sequence:
How many documents are there?
Show me ones with status code done.
List the document ids for any documents with the status code done and the type code paper.
SQL query sequence:
SELECT count(*) FROM Documents;
SELECT * FROM Documents WHERE document_status_code = "done"
SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper";
Final question: List the document ids for any documents with the status code done and the type code paper.
Final SQL: SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper";
Database: cre_Doc_Control_Systems
Question sequence:
What are the shipping agents' names?
Show all the documents with shipping agent named USPS?
What is the name of the shipping agent of the document with id 2?
SQL query sequence:
SELECT Ref_Shipping_Agents.shipping_agent_name FROM Ref_Shipping_Agents;
SELECT * FROM documents AS T1 JOIN Ref_Shipping_Agents AS T2 ON T1.shipping_agent_code = T2.shipping_agent_code WHERE T2.shipping_agent_name = "USPS";
SELECT Ref_Shipping_Agents.shipping_agent_name FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Documents.document_id = 2;
Final question: What is the name of the shipping agent of the document with id 2?
Final SQL: SELECT Ref_Shipping_Agents.shipping_agent_name FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Documents.document_id = 2;
Database: cre_Doc_Control_Systems
Question sequence:
How many documents are there?
How many documents were shipped by Fedex?
How about USPS?
SQL query sequence:
SELECT count(*) FROM Documents;
SELECT count(*) FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "Fedex";
SELECT count(*) FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS";
Final question: How many documents were shipped by USPS?
Final SQL: SELECT count(*) FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS";
Database: cre_Doc_Control_Systems
Question sequence:
What's the number of documents each shipping agent shipped?
Which agent shipped the least number of documents?
How about the most number of documents?
SQL query sequence:
SELECT Ref_Shipping_Agents.shipping_agent_name , count(Documents.document_id) FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code GROUP BY Ref_Shipping_Agents.shipping_agent_code;
SELECT Ref_Shipping_Agents.shipping_agent_name , count(Documents.document_id) FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code GROUP BY Ref_Shipping_Agents.shipping_agent_code ORDER BY count(Documents.document_id) ASC LIMIT 1;
SELECT Ref_Shipping_Agents.shipping_agent_name , count(Documents.document_id) FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code GROUP BY Ref_Shipping_Agents.shipping_agent_code ORDER BY count(Documents.document_id) DESC LIMIT 1;
Final question: Which shipping agent shipped the most documents? List the shipping agent name and the number of documents.
Final SQL: SELECT Ref_Shipping_Agents.shipping_agent_name , count(Documents.document_id) FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code GROUP BY Ref_Shipping_Agents.shipping_agent_code ORDER BY count(Documents.document_id) DESC LIMIT 1;
Database: cre_Doc_Control_Systems
Question sequence:
Show me the receipt number of the documents?
How about receipt date?
Show me that for document  with id 2?
How about for document with id 3?
SQL query sequence:
SELECT receipt_number FROM Documents;
SELECT receipt_date FROM Documents
SELECT receipt_date FROM Documents WHERE document_id = 3;
SELECT receipt_date FROM Documents WHERE document_id = 3;
Final question: What is the receipt date of the document with id 3?
Final SQL: SELECT receipt_date FROM Documents WHERE document_id = 3;
Database: cre_Doc_Control_Systems
Question sequence:
Show me the receipt_date of document with id 4?
What's its mailing date?
What address did it mail to?
SQL query sequence:
SELECT receipt_date FROM Documents WHERE document_id = 4;
SELECT Documents_Mailed.mailing_date FROM Addresses JOIN Documents_Mailed ON Documents_Mailed.mailed_to_address_id = Addresses.address_id WHERE document_id = 4;
SELECT Addresses.address_details FROM Addresses JOIN Documents_Mailed ON Documents_Mailed.mailed_to_address_id = Addresses.address_id WHERE document_id = 4;
Final question: What address was the document with id 4 mailed to?
Final SQL: SELECT Addresses.address_details FROM Addresses JOIN Documents_Mailed ON Documents_Mailed.mailed_to_address_id = Addresses.address_id WHERE document_id = 4;
Database: cre_Doc_Control_Systems
Question sequence:
Show me document with id 7.
Where did it mail to?
How about its mailing date?
SQL query sequence:
SELECT * FROM Documents;
SELECT Addresses.address_details FROM Addresses JOIN Documents_Mailed ON Documents_Mailed.mailed_to_address_id = Addresses.address_id WHERE document_id = 7;
SELECT mailing_date FROM Documents_Mailed WHERE document_id = 7;
Final question: What is the mail date of the document with id 7?
Final SQL: SELECT mailing_date FROM Documents_Mailed WHERE document_id = 7;
Database: cre_Doc_Control_Systems
Question sequence:
Show me document ids of documents with status working.
How about documents with the status done and type Paper?
Which of those were not shipped by agent named USPS?
SQL query sequence:
SELECT document_id FROM Documents WHERE document_status_code  =  "working";
SELECT document_id FROM Documents WHERE document_status_code  =  "done" AND document_type_code = "Paper";
SELECT document_id FROM Documents WHERE document_status_code  =  "done" AND document_type_code = "Paper" EXCEPT SELECT document_id FROM Documents JOIN Ref_Shipping_Agents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS";
Final question: List the document ids of documents with the status done and type Paper, which not shipped by the shipping agent named USPS.
Final SQL: SELECT document_id FROM Documents WHERE document_status_code  =  "done" AND document_type_code = "Paper" EXCEPT SELECT document_id FROM Documents JOIN Ref_Shipping_Agents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS";
Database: cre_Doc_Control_Systems
Question sequence:
What are document types of document with status done?
Show me the document id of those whose document status is done and document type is Paper.
Which of those are shipped by agent named USPS?
SQL query sequence:
SELECT document_type_code FROM Documents WHERE document_status_code  =  "done";
SELECT document_id FROM Documents WHERE document_status_code  =  "done" AND document_type_code = "Paper";
SELECT document_id FROM Documents WHERE document_status_code  =  "done" AND document_type_code = "Paper" INTERSECT SELECT document_id FROM Documents JOIN Ref_Shipping_Agents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS";
Final question: List document id of documents status is done and document type is Paper and the document is shipped by shipping agent named USPS.
Final SQL: SELECT document_id FROM Documents WHERE document_status_code  =  "done" AND document_type_code = "Paper" INTERSECT SELECT document_id FROM Documents JOIN Ref_Shipping_Agents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS";
Database: cre_Doc_Control_Systems
Question sequence:
Show me all about the documents.
Only list document with id 7.
What are its draft details?
SQL query sequence:
SELECT * FROM Documents;
SELECT * FROM Documents WHERE document_id = 7;
SELECT draft_details FROM Document_Drafts WHERE document_id = 7;
Final question: What is draft detail of the document with id 7?
Final SQL: SELECT draft_details FROM Document_Drafts WHERE document_id = 7;
Database: cre_Doc_Control_Systems
Question sequence:
Show me everything about draft copies.
What's the draft number of document with id 2?
How many draft copies does it have?
SQL query sequence:
SELECT * FROM Draft_Copies;
SELECT draft_number FROM Draft_Copies WHERE document_id = 2;
SELECT count(*) FROM Draft_Copies WHERE document_id = 2;
Final question: How many draft copies does the document with id 2 have?
Final SQL: SELECT count(*) FROM Draft_Copies WHERE document_id = 2;
Database: cre_Doc_Control_Systems
Question sequence:
What's draft number of the documents?
How about the draft copies? Show me how many draft copies each document has?
Which of the result has the most draft copies?
SQL query sequence:
SELECT draft_number FROM Draft_Copies;
SELECT document_id , count(copy_number) FROM Draft_Copies GROUP BY document_id;
SELECT document_id , count(copy_number) FROM Draft_Copies GROUP BY document_id ORDER BY count(copy_number) DESC LIMIT 1;
Final question: Which document has the most draft copies? List its document id and number of draft copies.
Final SQL: SELECT document_id , count(copy_number) FROM Draft_Copies GROUP BY document_id ORDER BY count(copy_number) DESC LIMIT 1;
Database: cre_Doc_Control_Systems
Question sequence:
How many draft copies does each document have? List the id of documents.
Which one has the maximum number of draft copies?
How about ones with more than 1 draft copies?
SQL query sequence:
SELECT document_id , count(*) FROM Draft_Copies GROUP BY document_id;
SELECT document_id , count(*) FROM Draft_Copies GROUP BY document_id ORDER BY draft_number DESC LIMIT 1;
SELECT document_id , count(*) FROM Draft_Copies GROUP BY document_id HAVING count(*)  >  1;
Final question: Which documents have more than 1 draft copies? List document id and number of draft copies.
Final SQL: SELECT document_id , count(*) FROM Draft_Copies GROUP BY document_id HAVING count(*)  >  1;
Database: cre_Doc_Control_Systems
Question sequence:
Show me all about the document with id 1.
What about role codes of the employees who appeared in the circulation history of it?
What about these employees' names?
SQL query sequence:
SELECT * FROM Documents WHERE document_id = 1;
SELECT Employees.role_code FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id WHERE Circulation_History.document_id = 1;
SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id WHERE Circulation_History.document_id = 1;
Final question: List all employees in the circulation history of the document with id 1. List the employee's name.
Final SQL: SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id WHERE Circulation_History.document_id = 1;
Database: cre_Doc_Control_Systems
Question sequence:
For each employee, list the number of documents which showed up in the circulation history.
Who showed up the most times?
What about the names of the employees who have not showed up in any circulation history of documents.
SQL query sequence:
SELECT Employees.employee_name, count(Circulation_History.document_id) FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id GROUP BY Employees.employee_id;
SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id GROUP BY Employees.employee_id ORDER BY count(Circulation_History.document_id) DESC LIMIT 1;
SELECT employee_name FROM Employees EXCEPT SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id
Final question: List the employees who have not showed up in any circulation history of documents. List the employee's name.
Final SQL: SELECT employee_name FROM Employees EXCEPT SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id
Database: cre_Doc_Control_Systems
Question sequence:
Show me about the Circulation History.
Which employee has showed up in the least Circulation History documents?
How about the most circulation history documents? Show the number of circulation history documents as well.
SQL query sequence:
SELECT * FROM Circulation_History
SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id GROUP BY Circulation_History.document_id , Circulation_History.draft_number , Circulation_History.copy_number ORDER BY count(*) ASC LIMIT 1;
SELECT Employees.employee_name , count(*) FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id GROUP BY Circulation_History.document_id , Circulation_History.draft_number , Circulation_History.copy_number ORDER BY count(*) DESC LIMIT 1;
Final question: Which employee has showed up in most circulation history documents. List the employee's name and the number of drafts and copies.
Final SQL: SELECT Employees.employee_name , count(*) FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id GROUP BY Circulation_History.document_id , Circulation_History.draft_number , Circulation_History.copy_number ORDER BY count(*) DESC LIMIT 1;
Database: customers_and_products_contacts
Question sequence:
Show all the address information.
How about those in country USA?
How many of them are there?
SQL query sequence:
SELECT * FROM addresses
SELECT * FROM addresses WHERE country  =  'USA'
SELECT count(*) FROM addresses WHERE country  =  'USA'
Final question: How many addresses are there in country USA?
Final SQL: SELECT count(*) FROM addresses WHERE country  =  'USA'
Database: customers_and_products_contacts
Question sequence:
Show all cities in the addresses.
Only show unique names.
SQL query sequence:
SELECT city FROM addresses
SELECT DISTINCT city FROM addresses
Final question: Show all distinct cities in the address record.
Final SQL: SELECT DISTINCT city FROM addresses
Database: customers_and_products_contacts
Question sequence:
Show the state for each address.
Also show the number of addresses in each of them.
SQL query sequence:
SELECT state_province_county from addresses
SELECT state_province_county ,  count(*) FROM addresses GROUP BY state_province_county
Final question: Show each state and the number of addresses in each state.
Final SQL: SELECT state_province_county ,  count(*) FROM addresses GROUP BY state_province_county
Database: customers_and_products_contacts
Question sequence:
Show the ids of all customers.
What about those who have address information?
Show the names of those who don't have it.
Also show their phone numbers.
SQL query sequence:
SELECT customer_id FROM customers
SELECT customer_id FROM customer_address_history
SELECT customer_name  FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM customer_address_history)
SELECT customer_name ,  customer_phone FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM customer_address_history)
Final question: Show names and phones of customers who do not have address information.
Final SQL: SELECT customer_name ,  customer_phone FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM customer_address_history)
Database: customers_and_products_contacts
Question sequence:
Show the names of all customers.
Also show the number of orders each of them has.
Sort the names in descending order of the number of orders.
Who has the most?
SQL query sequence:
SELECT customer_name FROM customers
SELECT T1.customer_name, count(*) FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id
SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC
SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
Final question: Show the name of the customer who has the most orders.
Final SQL: SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
Database: customers_and_products_contacts
Question sequence:
Show the product type code for all products.
For each of them, count the number of products.
Which of them have at least two products?
SQL query sequence:
SELECT product_type_code FROM products
SELECT product_type_code, count(*) FROM products GROUP BY product_type_code
SELECT product_type_code FROM products GROUP BY product_type_code HAVING count(*)  >=  2
Final question: Show the product type codes which have at least two products.
Final SQL: SELECT product_type_code FROM products GROUP BY product_type_code HAVING count(*)  >=  2
Database: customers_and_products_contacts
Question sequence:
Show the names of all customers.
Who has an order in completed status?
Who has an order in part status?
Who has both?
SQL query sequence:
SELECT customer_name FROM customers
SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id WHERE T2.order_status_code  =  'Completed'
SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id WHERE T2.order_status_code  =  'Part'
SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id WHERE T2.order_status_code  =  'Completed' INTERSECT SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id WHERE T2.order_status_code  =  'Part'
Final question: Show the names of customers who have both an order in completed status and an order in part status.
Final SQL: SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id WHERE T2.order_status_code  =  'Completed' INTERSECT SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id WHERE T2.order_status_code  =  'Part'
Database: customers_and_products_contacts
Question sequence:
Show the name for all customers.
Also show their phone number and payment method code.
Sort the results in descending order of customer number.
SQL query sequence:
SELECT customer_name FROM customers
SELECT customer_name ,  customer_phone ,  payment_method_code FROM customers
SELECT customer_name ,  customer_phone ,  payment_method_code FROM customers ORDER BY customer_number DESC
Final question: Show the name, phone, and payment method code for all customers in descending order of customer number.
Final SQL: SELECT customer_name ,  customer_phone ,  payment_method_code FROM customers ORDER BY customer_number DESC
Database: customers_and_products_contacts
Question sequence:
Show the product name for all products.
Show the product name and all the order quantities for each product.
For each of those products, what is the total order quantity?
SQL query sequence:
SELECT product_name from products
SELECT T1.product_name ,  T2.order_quantity FROM products AS T1 JOIN order_items AS T2 ON T1.product_id  =  T2.product_id
SELECT T1.product_name ,  sum(T2.order_quantity) FROM products AS T1 JOIN order_items AS T2 ON T1.product_id  =  T2.product_id GROUP BY T1.product_id
Final question: Show the product name and total order quantity for each product.
Final SQL: SELECT T1.product_name ,  sum(T2.order_quantity) FROM products AS T1 JOIN order_items AS T2 ON T1.product_id  =  T2.product_id GROUP BY T1.product_id
Database: customers_and_products_contacts
Question sequence:
Show the price for all products.
What is the minimum, maximum, and average of them?
SQL query sequence:
SELECT product_price FROM products
SELECT min(product_price) ,  max(product_price) ,  avg(product_price) FROM products
Final question: Show the minimum, maximum, average price for all products.
Final SQL: SELECT min(product_price) ,  max(product_price) ,  avg(product_price) FROM products
Database: customers_and_products_contacts
Question sequence:
What is the average price for prodcuts?
Show product information for products more expensive than the average.
How many such products are there?
SQL query sequence:
SELECT avg(product_price) FROM products
SELECT * FROM products WHERE product_price  >  (SELECT avg(product_price) FROM products)
SELECT count(*) FROM products WHERE product_price  >  (SELECT avg(product_price) FROM products)
Final question: How many products have a price higher than the average?
Final SQL: SELECT count(*) FROM products WHERE product_price  >  (SELECT avg(product_price) FROM products)