aherntech/sparc huggingface dataset:
Database: customer_deliveries
Question sequence:
What state or province are the most customer addresses located?
How many customers have addresses in the state of California
What are their names and phone numbers?
SQL query sequence:
SELECT state_province_county, count(*) FROM customer_addresses AS t1 JOIN addresses AS t2 ON t1.address_id = t2.address_id GROUP BY state_province_county ORDER BY count(*) DESC LIMIT 1
SELECT count(*) FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id  =  t2.customer_id JOIN addresses AS t3 ON t2.address_id  =  t3.address_id WHERE t3.state_province_county  =  'California'
SELECT t1.customer_name , t1.customer_phone FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id  =  t2.customer_id JOIN addresses AS t3 ON t2.address_id  =  t3.address_id WHERE t3.state_province_county  =  'California'
Final question: Find the names and phone numbers of customers living in California state.
Final SQL: SELECT t1.customer_name ,  t1.customer_phone FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id  =  t2.customer_id JOIN addresses AS t3 ON t2.address_id  =  t3.address_id WHERE t3.state_province_county  =  'California'
Database: customer_deliveries
Question sequence:
What are all the different employee address details?
At which adresses do no employees live?
What states or provinces are they in?
SQL query sequence:
SELECT DISTINCT address_details FROM addresses AS t1 JOIN employees AS t2 ON t1.address_id = t2.employee_address_id
SELECT * FROM addresses WHERE address_id NOT IN (SELECT employee_address_id FROM employees)
SELECT state_province_county FROM addresses WHERE address_id NOT IN (SELECT employee_address_id FROM employees)
Final question: Find the states which do not have any employee in their record.
Final SQL: SELECT state_province_county FROM addresses WHERE address_id NOT IN (SELECT employee_address_id FROM employees)
Database: customer_deliveries
Question sequence:
What is the customer ID of the person who became a customer most recently?
What is their name?
How about the earliest 5 customers?
SQL query sequence:
SELECT customer_id FROM customers ORDER BY date_became_customer DESC LIMIT 1
SELECT customer_name FROM customers ORDER BY date_became_customer DESC LIMIT 1
SELECT customer_name FROM customers ORDER BY date_became_customer LIMIT 5
Final question: Find the name of the first 5 customers.
Final SQL: SELECT customer_name FROM customers ORDER BY date_became_customer LIMIT 5
Database: customer_deliveries
Question sequence:
Order all customer payment methods alphabetically.
Which is last alphabetically?
Which appears most often?
SQL query sequence:
SELECT payment_method FROM customers ORDER BY payment_method
SELECT payment_method FROM customers ORDER BY payment_method DESC LIMIT 1
SELECT payment_method FROM customers GROUP BY payment_method ORDER BY count(*) DESC LIMIT 1
Final question: Find the payment method that is used most frequently.
Final SQL: SELECT payment_method FROM customers GROUP BY payment_method ORDER BY count(*) DESC LIMIT 1
Database: customer_deliveries
Question sequence:
What are all location codes for the delivery locations?
Which route has had the fewest orders delivered?
Which route has the highest number of delivery locations?
SQL query sequence:
SELECT location_code FROM delivery_route_locations
SELECT route_id FROM order_deliveries AS t1 JOIN delivery_route_locations AS t2 ON t1.location_code = t2.location_code ORDER BY t2.route_id LIMIT 1
SELECT t1.route_name FROM delivery_routes AS t1 JOIN delivery_route_locations AS t2 ON t1.route_id  =  t2.route_id GROUP BY t1.route_id ORDER BY count(*) DESC LIMIT 1
Final question: Find the name of route that has the highest number of deliveries.
Final SQL: SELECT t1.route_name FROM delivery_routes AS t1 JOIN delivery_route_locations AS t2 ON t1.route_id  =  t2.route_id GROUP BY t1.route_id ORDER BY count(*) DESC LIMIT 1
Database: document_management
Question sequence:
What are all the documents?
Show the name and access counts of them in alphabetic order of the name.
SQL query sequence:
SELECT * FROM documents
SELECT document_name ,  access_count FROM documents ORDER BY document_name
Final question: Find the name and access counts of all documents, in alphabetic order of the document name.
Final SQL: SELECT document_name ,  access_count FROM documents ORDER BY document_name
Database: document_management
Question sequence:
What are the names and access counts of all the documents?
Which one has been accessed the greatest number of times?
SQL query sequence:
SELECT document_name, access_count FROM documents
SELECT document_name ,  access_count FROM documents ORDER BY access_count DESC LIMIT 1
Final question: Find the name of the document that has been accessed the greatest number of times, as well as the count of how many times it has been accessed?
Final SQL: SELECT document_name ,  access_count FROM documents ORDER BY access_count DESC LIMIT 1
Database: document_management
Question sequence:
What are all the documents?
Which document types are there?
Which types have more than 4 documents?
SQL query sequence:
SELECT * FROM documents
SELECT document_type_code FROM documents GROUP BY document_type_code
SELECT document_type_code FROM documents GROUP BY document_type_code HAVING count(*)  >  4
Final question: Find the types of documents with more than 4 documents.
Final SQL: SELECT document_type_code FROM documents GROUP BY document_type_code HAVING count(*)  >  4
Database: document_management
Question sequence:
What are all the documents?
What are the total access counts of documents in terms of document type?
Which is the largest among them?
SQL query sequence:
SELECT * FROM documents
SELECT sum(access_count) FROM documents GROUP BY document_type_code
SELECT sum(access_count) FROM documents GROUP BY document_type_code ORDER BY count(*) DESC LIMIT 1
Final question: Find the total access count of all documents in the most popular document type.
Final SQL: SELECT sum(access_count) FROM documents GROUP BY document_type_code ORDER BY count(*) DESC LIMIT 1
Database: document_management
Question sequence:
What are access counts all the documents?
Show their average.
SQL query sequence:
SELECT access_count FROM documents
SELECT avg(access_count) FROM documents
Final question: What is the average access count of documents?
Final SQL: SELECT avg(access_count) FROM documents
Database: document_management
Question sequence:
What are all the documents?
Show the type of the one named "David CV".
SQL query sequence:
SELECT * FROM documents
SELECT document_type_code FROM documents WHERE document_name  =  "David CV"
Final question: What is the type of the document named "David CV"?
Final SQL: SELECT document_type_code FROM documents WHERE document_name  =  "David CV"
Database: document_management
Question sequence:
What are all the documents?
Which document types have more than 10000 total access number?
SQL query sequence:
SELECT * FROM documents
SELECT document_type_code FROM documents GROUP BY document_type_code HAVING sum(access_count)  >  10000
Final question: What document types do have more than 10000 total access number.
Final SQL: SELECT document_type_code FROM documents GROUP BY document_type_code HAVING sum(access_count)  >  10000
Database: document_management
Question sequence:
What is the document named "David CV"?
What are all the section titils of it?
SQL query sequence:
SELECT * FROM documents WHERE document_name  =  "David CV"
SELECT t2.section_title FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code  =  t2.document_code WHERE t1.document_name  =  "David CV"
Final question: What are all the section titles of the document named "David CV"?
Final SQL: SELECT t2.section_title FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code  =  t2.document_code WHERE t1.document_name  =  "David CV"
Database: document_management
Question sequence:
What are all the documents?
Show those without any sections.
SQL query sequence:
SELECT * FROM documents
SELECT document_name FROM documents WHERE document_code NOT IN (SELECT document_code FROM document_sections)
Final question: Find all the name of documents without any sections.
Final SQL: SELECT document_name FROM documents WHERE document_code NOT IN (SELECT document_code FROM document_sections)
Database: document_management
Question sequence:
What are all the documents with functional area "Acknowledgement"?
Show the average access counts for each of them.
SQL query sequence:
SELECT * FROM documents AS t1 JOIN document_functional_areas AS t2 ON t1.document_code  =  t2.document_code JOIN functional_areas AS t3 ON t2.functional_area_code  =  t3.functional_area_code WHERE t3.functional_area_description  =  "Acknowledgement"
SELECT avg(t1.access_count) FROM documents AS t1 JOIN document_functional_areas AS t2 ON t1.document_code  =  t2.document_code JOIN functional_areas AS t3 ON t2.functional_area_code  =  t3.functional_area_code WHERE t3.functional_area_description  =  "Acknowledgement"
Final question: Find the average access counts of documents with functional area "Acknowledgement".
Final SQL: SELECT avg(t1.access_count) FROM documents AS t1 JOIN document_functional_areas AS t2 ON t1.document_code  =  t2.document_code JOIN functional_areas AS t3 ON t2.functional_area_code  =  t3.functional_area_code WHERE t3.functional_area_description  =  "Acknowledgement"
Database: document_management
Question sequence:
What are all the documents?
Show those without any images.
SQL query sequence:
SELECT * FROM documents
SELECT document_name FROM documents EXCEPT SELECT t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code  =  t2.document_code JOIN document_sections_images AS t3 ON t2.section_id  =  t3.section_id
Final question: Find names of the document without any images.
Final SQL: SELECT document_name FROM documents EXCEPT SELECT t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code  =  t2.document_code JOIN document_sections_images AS t3 ON t2.section_id  =  t3.section_id
Database: document_management
Question sequence:
What are all the documents?
Show their names in the order of number of sections.
What is the name of the one with the most number of sections?
SQL query sequence:
SELECT * FROM documents
SELECT t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code  =  t2.document_code GROUP BY t1.document_code ORDER BY count(*)
SELECT t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code  =  t2.document_code GROUP BY t1.document_code ORDER BY count(*) DESC LIMIT 1
Final question: What is the name of the document with the most number of sections?
Final SQL: SELECT t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code  =  t2.document_code GROUP BY t1.document_code ORDER BY count(*) DESC LIMIT 1
Database: document_management
Question sequence:
What are the names of all the documents?
Show those that contain "CV".
SQL query sequence:
SELECT document_name FROM documents
SELECT document_name FROM documents WHERE document_name LIKE "%CV%"
Final question: List all the document names which contains "CV".
Final SQL: SELECT document_name FROM documents WHERE document_name LIKE "%CV%"
Database: document_management
Question sequence:
Who are all the users?
Show those who are logged in.
SQL query sequence:
SELECT * FROM users
SELECT count(*) FROM users WHERE user_login  =  1
Final question: How many users are logged in?
Final SQL: SELECT count(*) FROM users WHERE user_login  =  1
Database: document_management
Question sequence:
What are all the users that have logged in?
Among those users, which role is the most popular one?
Show the description of that role.
SQL query sequence:
SELECT * FROM users WHERE user_login = 1
SELECT role_code FROM users WHERE user_login  =  1 GROUP BY role_code ORDER BY count(*) DESC LIMIT 1
SELECT role_description FROM ROLES WHERE role_code  =  (SELECT role_code FROM users WHERE user_login  =  1 GROUP BY role_code ORDER BY count(*) DESC LIMIT 1)
Final question: Find the description of the most popular role among the users that have logged in.
Final SQL: SELECT role_description FROM ROLES WHERE role_code  =  (SELECT role_code FROM users WHERE user_login  =  1 GROUP BY role_code ORDER BY count(*) DESC LIMIT 1)
Database: document_management
Question sequence:
What are all the documents?
What are the average access counts in terms of each document structure?
Show the one with the least popular structure.
SQL query sequence:
SELECT * FROM documents
SELECT avg(access_count) FROM documents GROUP BY document_structure_code
SELECT avg(access_count) FROM documents GROUP BY document_structure_code ORDER BY count(*) ASC LIMIT 1
Final question: Find the average access count of documents with the least popular structure.
Final SQL: SELECT avg(access_count) FROM documents GROUP BY document_structure_code ORDER BY count(*) ASC LIMIT 1
Database: document_management
Question sequence:
Show all the images.
Show their names and URLs in the order of their names.
SQL query sequence:
SELECT * FROM images
SELECT image_name ,  image_url FROM images ORDER BY image_name
Final question: List all the image name and URLs in the order of their names.
Final SQL: SELECT image_name ,  image_url FROM images ORDER BY image_name
Database: document_management
Question sequence:
What are all the users?
What are the different kinds of roles among them?
Show the number of users in each role.
SQL query sequence:
SELECT * FROM users
SELECT role_code FROM users GROUP BY role_code
SELECT count(*) ,  role_code FROM users GROUP BY role_code
Final question: Find the number of users in each role.
Final SQL: SELECT count(*) ,  role_code FROM users GROUP BY role_code
Database: insurance_fnol
Question sequence:
Show me all the policy types.
Show me the type with most records in the database.
SQL query sequence:
SELECT policy_type_code FROM available_policies
SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY count(*) DESC LIMIT 1
Final question: Which policy type has the most records in the database?
Final SQL: SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY count(*) DESC LIMIT 1
Database: insurance_fnol
Question sequence:
What is the most popular policy type?
Show me all the customer phone numbers associated with it.
SQL query sequence:
SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY count(*) DESC LIMIT 1
SELECT customer_phone FROM available_policies WHERE policy_type_code  =  (SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY count(*) DESC LIMIT 1)
Final question: What are all the customer phone numbers under the most popular policy type?
Final SQL: SELECT customer_phone FROM available_policies WHERE policy_type_code  =  (SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY count(*) DESC LIMIT 1)
Database: insurance_fnol
Question sequence:
Show me the policy type used by more than 3 customers.
Show me the same for more than 4 customers.
SQL query sequence:
SELECT policy_type_code FROM available_policies GROUP BY policy_type_code HAVING count(*)  >  3
SELECT policy_type_code FROM available_policies GROUP BY policy_type_code HAVING count(*)  >  4
Final question: Find the policy type used by more than 4 customers.
Final SQL: SELECT policy_type_code FROM available_policies GROUP BY policy_type_code HAVING count(*)  >  4
Database: insurance_fnol
Question sequence:
What is the maximum amount of settlements?
What is the total amount of settlements?
What is the average?
SQL query sequence:
SELECT max(settlement_amount) FROM settlements
SELECT sum(settlement_amount) FROM settlements
SELECT avg(settlement_amount) FROM settlements
Final question: Find the total and average amount of settlements.
Final SQL: SELECT sum(settlement_amount) ,  avg(settlement_amount) FROM settlements
Database: insurance_fnol
Question sequence:
Find the name of services that have been used in first notification of loss.
Find services used more than twice in first notification of loss.
SQL query sequence:
SELECT t2.service_name FROM first_notification_of_loss AS t1 JOIN services AS t2 ON t1.service_id  =  t2.service_id GROUP BY t1.service_id HAVING count(*)  >  0
SELECT t2.service_name FROM first_notification_of_loss AS t1 JOIN services AS t2 ON t1.service_id  =  t2.service_id GROUP BY t1.service_id HAVING count(*)  >  2
Final question: Find the name of services that have been used for more than 2 times in first notification of loss.
Final SQL: SELECT t2.service_name FROM first_notification_of_loss AS t1 JOIN services AS t2 ON t1.service_id  =  t2.service_id GROUP BY t1.service_id HAVING count(*)  >  2
Database: insurance_fnol
Question sequence:
What is the ID of the claim that has the smallest amount of total settlement?
What is its effective date?
Show me the same for the effective date of claim with largest amount of total sum.
SQL query sequence:
SELECT t1.Claim_ID FROM claims AS t1 JOIN settlements AS t2 ON t1.claim_id  =  t2.claim_id GROUP BY t1.claim_id ORDER BY sum(t2.settlement_amount) ASC LIMIT 1
SELECT t1.Effective_Date FROM claims AS t1 JOIN settlements AS t2 ON t1.claim_id  =  t2.claim_id GROUP BY t1.claim_id ORDER BY sum(t2.settlement_amount) ASC LIMIT 1
SELECT t1.Effective_Date FROM claims AS t1 JOIN settlements AS t2 ON t1.claim_id  =  t2.claim_id GROUP BY t1.claim_id ORDER BY sum(t2.settlement_amount) DESC LIMIT 1
Final question: What is the effective date of the claim that has the largest amount of total settlement?
Final SQL: SELECT t1.Effective_Date FROM claims AS t1 JOIN settlements AS t2 ON t1.claim_id  =  t2.claim_id GROUP BY t1.claim_id ORDER BY sum(t2.settlement_amount) DESC LIMIT 1
Database: insurance_fnol
Question sequence:
Show me the policies listed for the customer named "Dayana Robel".
How many are there?
SQL query sequence:
SELECT * FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id  =  t2.customer_id WHERE t1.customer_name  =  "Dayana Robel"
SELECT count(*) FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id  =  t2.customer_id WHERE t1.customer_name  =  "Dayana Robel"
Final question: How many policies are listed for the customer named "Dayana Robel"?
Final SQL: SELECT count(*) FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id  =  t2.customer_id WHERE t1.customer_name  =  "Dayana Robel"
Database: insurance_fnol
Question sequence:
What is the name of the customer who has the least policies listed?
How about the most policies listed?
SQL query sequence:
SELECT t1.customer_name FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id  =  t2.customer_id GROUP BY t1.customer_name ORDER BY count(*) ASC LIMIT 1
SELECT t1.customer_name FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id  =  t2.customer_id GROUP BY t1.customer_name ORDER BY count(*) DESC LIMIT 1
Final question: What is the name of the customer who has the most policies listed?
Final SQL: SELECT t1.customer_name FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id  =  t2.customer_id GROUP BY t1.customer_name ORDER BY count(*) DESC LIMIT 1
Database: insurance_fnol
Question sequence:
What is the phone number of the customer named "Dayana Robel"?
Show me all the policy types associated with that phone number.
SQL query sequence:
SELECT DISTINCT t3.customer_phone FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id  =  t2.customer_id JOIN available_policies AS t3 ON t2.policy_id  =  t3.policy_id WHERE t1.customer_name  =  "Dayana Robel"
SELECT DISTINCT t3.policy_type_code FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id  =  t2.customer_id JOIN available_policies AS t3 ON t2.policy_id  =  t3.policy_id WHERE t1.customer_name  =  "Dayana Robel"
Final question: What are all the policy types of the customer named "Dayana Robel"?
Final SQL: SELECT DISTINCT t3.policy_type_code FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id  =  t2.customer_id JOIN available_policies AS t3 ON t2.policy_id  =  t3.policy_id WHERE t1.customer_name  =  "Dayana Robel"
Database: insurance_fnol
Question sequence:
What is the name of the customer who has the most policies listed?
How many policy types has the customer listed?
List all of them please.
SQL query sequence:
SELECT t1.customer_name FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id  =  t2.customer_id GROUP BY t1.customer_name ORDER BY count(*) DESC LIMIT 1
SELECT DISTINCT count(*) FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id  =  t2.customer_id JOIN available_policies AS t3 ON t2.policy_id  =  t3.policy_id WHERE t1.customer_name  =  (SELECT t1.customer_name FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id  =  t2.customer_id GROUP BY t1.customer_name ORDER BY count(*) DESC LIMIT 1)
SELECT DISTINCT t3.policy_type_code FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id  =  t2.customer_id JOIN available_policies AS t3 ON t2.policy_id  =  t3.policy_id WHERE t1.customer_name  =  (SELECT t1.customer_name FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id  =  t2.customer_id GROUP BY t1.customer_name ORDER BY count(*) DESC LIMIT 1)
Final question: What are all the policy types of the customer that has the most policies listed?
Final SQL: SELECT DISTINCT t3.policy_type_code FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id  =  t2.customer_id JOIN available_policies AS t3 ON t2.policy_id  =  t3.policy_id WHERE t1.customer_name  =  (SELECT t1.customer_name FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id  =  t2.customer_id GROUP BY t1.customer_name ORDER BY count(*) DESC LIMIT 1)
Database: insurance_fnol
Question sequence:
Find the ids of customers without first notification of loss record.
Show me their names.
SQL query sequence:
SELECT customer_id FROM customers EXCEPT SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id  =  t2.customer_id
SELECT customer_name FROM customers EXCEPT SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id  =  t2.customer_id
Final question: Find the names of users who do not have a first notification of loss record.
Final SQL: SELECT customer_name FROM customers EXCEPT SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id  =  t2.customer_id
Database: insurance_fnol
Question sequence:
Find me names of customers who have used the service "Close a policy".
Find me names of customers who have also used the service "Upgrade a policy".
Find me names of customers who have used either of the two services.
SQL query sequence:
SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id  =  t2.customer_id JOIN services AS t3 ON t2.service_id  =  t3.service_id WHERE t3.service_name  =  "Close a policy"
SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id  =  t2.customer_id JOIN services AS t3 ON t2.service_id  =  t3.service_id WHERE t3.service_name  =  "Close a policy" AND t3.service_name = "Upgrade a policy"
SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id  =  t2.customer_id JOIN services AS t3 ON t2.service_id  =  t3.service_id WHERE t3.service_name  =  "Close a policy" OR t3.service_name  =  "Upgrade a policy"
Final question: Find the names of customers who have used either the service "Close a policy" or the service "Upgrade a policy".
Final SQL: SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id  =  t2.customer_id JOIN services AS t3 ON t2.service_id  =  t3.service_id WHERE t3.service_name  =  "Close a policy" OR t3.service_name  =  "Upgrade a policy"