aherntech/sparc huggingface dataset:
Database: customers_and_invoices
Question sequence:
Show the invoice number of each transaction.
Also show the invoice date.
Also show the number of transactions for each of them.
Which one has the most transactions?
SQL query sequence:
SELECT invoice_number from Financial_transactions
SELECT T2.invoice_number ,  T2.invoice_date FROM Financial_transactions AS T1 JOIN Invoices AS T2 ON T1.invoice_number  =  T2.invoice_number
SELECT T2.invoice_number ,  T2.invoice_date, count(*) FROM Financial_transactions AS T1 JOIN Invoices AS T2 ON T1.invoice_number  =  T2.invoice_number GROUP BY T1.invoice_number
SELECT T2.invoice_number ,  T2.invoice_date FROM Financial_transactions AS T1 JOIN Invoices AS T2 ON T1.invoice_number  =  T2.invoice_number GROUP BY T1.invoice_number ORDER BY count(*) DESC LIMIT 1
Final question: What is the invoice number and invoice date for the invoice with most number of transactions?
Final SQL: SELECT T2.invoice_number ,  T2.invoice_date FROM Financial_transactions AS T1 JOIN Invoices AS T2 ON T1.invoice_number  =  T2.invoice_number GROUP BY T1.invoice_number ORDER BY count(*) DESC LIMIT 1
Database: customers_and_invoices
Question sequence:
Show the information for all invoices.
How many are there?
SQL query sequence:
SELECT * FROM Invoices
SELECT count(*) FROM Invoices
Final question: How many invoices do we have?
Final SQL: SELECT count(*) FROM Invoices
Database: customers_and_invoices
Question sequence:
Show the invoice date for all invoices.
Also show their order ids.
Also show their order details.
SQL query sequence:
SELECT invoice_date from Invoices
SELECT invoice_date ,  order_id FROM Invoices
SELECT T1.invoice_date ,  T1.order_id ,  T2.order_details FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id  =  T2.order_id
Final question: Show invoice dates and order id and details for all invoices.
Final SQL: SELECT T1.invoice_date ,  T1.order_id ,  T2.order_details FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id  =  T2.order_id
Database: customers_and_invoices
Question sequence:
Show the order id for each invoice.
What is the number of invoices for each order?
SQL query sequence:
SELECT order_id FROM Invoices
SELECT order_id ,  count(*) FROM Invoices GROUP BY order_id
Final question: Show the order ids and the number of invoices for each order.
Final SQL: SELECT order_id ,  count(*) FROM Invoices GROUP BY order_id
Database: customers_and_invoices
Question sequence:
Show the order id and order details for all orders.
For each of them, count the number of invoices as well.
Which of them have more than two?
SQL query sequence:
SELECT order_id ,  order_details FROM Orders
SELECT T2.order_id ,  T2.order_details, count(*) FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id  =  T2.order_id GROUP BY T2.order_id
SELECT T2.order_id ,  T2.order_details FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id  =  T2.order_id GROUP BY T2.order_id HAVING count(*)  >  2
Final question: What is the order id and order details for the order more than two invoices.
Final SQL: SELECT T2.order_id ,  T2.order_details FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id  =  T2.order_id GROUP BY T2.order_id HAVING count(*)  >  2
Database: customers_and_invoices
Question sequence:
Show the last name, id, and phone number for all customers.
For each of them, show the number of orders as well.
Sort them in descending order of the number of orders.
Who has the most?
SQL query sequence:
SELECT customer_last_name ,  customer_id ,  phone_number FROM Customers
SELECT T2.customer_last_name ,  T1.customer_id ,  T2.phone_number , count(*) FROM Orders AS T1 JOIN Customers AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id
SELECT T2.customer_last_name ,  T1.customer_id ,  T2.phone_number FROM Orders AS T1 JOIN Customers AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC
SELECT T2.customer_last_name ,  T1.customer_id ,  T2.phone_number FROM Orders AS T1 JOIN Customers AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
Final question: What is the customer last name, id and phone number with most number of orders?
Final SQL: SELECT T2.customer_last_name ,  T1.customer_id ,  T2.phone_number FROM Orders AS T1 JOIN Customers AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
Database: customers_and_invoices
Question sequence:
Show all product names
Which of them has an order?
Which of them don't?
SQL query sequence:
SELECT product_name FROM Products
SELECT T1.product_name FROM Products AS T1 JOIN Order_items AS T2 ON T1.product_id  =  T2.product_id
SELECT product_name FROM Products EXCEPT SELECT T1.product_name FROM Products AS T1 JOIN Order_items AS T2 ON T1.product_id  =  T2.product_id
Final question: Show all product names without an order.
Final SQL: SELECT product_name FROM Products EXCEPT SELECT T1.product_name FROM Products AS T1 JOIN Order_items AS T2 ON T1.product_id  =  T2.product_id
Database: customers_and_invoices
Question sequence:
Show all product names
Also show the quantity ordered for each order of a product.
What is the total quantity ordered for each product name?
SQL query sequence:
SELECT product_name FROM Products
SELECT T2.product_name ,  T1.product_quantity FROM Order_items AS T1 JOIN Products AS T2 ON T1.product_id  =  T2.product_id
SELECT T2.product_name ,  sum(T1.product_quantity) FROM Order_items AS T1 JOIN Products AS T2 ON T1.product_id  =  T2.product_id GROUP BY T2.product_name
Final question: Show all product names and the total quantity ordered for each product name.
Final SQL: SELECT T2.product_name ,  sum(T1.product_quantity) FROM Order_items AS T1 JOIN Products AS T2 ON T1.product_id  =  T2.product_id GROUP BY T2.product_name
Database: customers_and_invoices
Question sequence:
Show the order id for each order item.
For each of those ids, how many items were ordered?
SQL query sequence:
SELECT order_id FROM Order_items
SELECT order_id ,  count(*) FROM Order_items GROUP BY order_id
Final question: Show the order ids and the number of items in each order.
Final SQL: SELECT order_id ,  count(*) FROM Order_items GROUP BY order_id
Database: customers_and_invoices
Question sequence:
Show the product id for all orders.
Also show the order id.
For each of those product ids, what is the number of unique orders containing each product?
SQL query sequence:
SELECT product_id FROM Order_items
SELECT product_id, order_id FROM Order_items
SELECT product_id ,  count(DISTINCT order_id) FROM Order_items GROUP BY product_id
Final question: Show the product ids and the number of unique orders containing each product.
Final SQL: SELECT product_id ,  count(DISTINCT order_id) FROM Order_items GROUP BY product_id
Database: customers_and_invoices
Question sequence:
Show all product names.
For each of them, what is the number of order items on each?
SQL query sequence:
SELECT product_name FROM Products
SELECT T2.product_name ,  count(*) FROM Order_items AS T1 JOIN Products AS T2 ON T1.product_id  =  T2.product_id JOIN Orders AS T3 ON T3.order_id  =  T1.order_id GROUP BY T2.product_name
Final question: Show all product names and the number of order items on each product.
Final SQL: SELECT T2.product_name ,  count(*) FROM Order_items AS T1 JOIN Products AS T2 ON T1.product_id  =  T2.product_id JOIN Orders AS T3 ON T3.order_id  =  T1.order_id GROUP BY T2.product_name
Database: customers_and_invoices
Question sequence:
Show the order id for all order items.
Also show the product id.
For each order, show the number of products.
SQL query sequence:
SELECT order_id FROM Order_items
SELECT order_id,  product_id FROM Order_items
SELECT order_id ,  count(DISTINCT product_id) FROM Order_items GROUP BY order_id
Final question: Show order ids and the number of products in each order.
Final SQL: SELECT order_id ,  count(DISTINCT product_id) FROM Order_items GROUP BY order_id
Database: customers_and_invoices
Question sequence:
Show the order id for each order item.
For each of those items, also show the product quantities.
For each order, what is the total quantity?
SQL query sequence:
SELECT order_id FROM Order_items
SELECT order_id ,  product_quantity FROM Order_items
SELECT order_id ,  sum(product_quantity) FROM Order_items GROUP BY order_id
Final question: Show order ids and the total quantity in each order.
Final SQL: SELECT order_id ,  sum(product_quantity) FROM Order_items GROUP BY order_id
Database: department_management
Question sequence:
Show all information about department heads.
How many heads of departments are there?
How many heads of department are older than 56?
SQL query sequence:
SELECT * FROM head
SELECT count(*) FROM head
SELECT count(*) FROM head WHERE age  >  56
Final question: How many heads of the departments are older than 56 ?
Final SQL: SELECT count(*) FROM head WHERE age  >  56
Database: department_management
Question sequence:
Show the names of the heads of departments.
Show the state where each department head was born.
Show the age of the heads of departments.
Please order this information by heads' ages.
SQL query sequence:
SELECT name FROM head
SELECT born_state FROM head
SELECT age FROM head
SELECT name ,  born_state ,  age FROM head ORDER BY age
Final question: List the name, born state and age of the heads of departments ordered by age.
Final SQL: SELECT name ,  born_state ,  age FROM head ORDER BY age
Database: department_management
Question sequence:
List the creation year of each department.
List the name of each department.
List the budget of each department.
List the creation year, name and budget of each department.
SQL query sequence:
SELECT creation FROM department
SELECT name FROM department
SELECT budget_in_billions FROM department
SELECT creation ,  name ,  budget_in_billions FROM department
Final question: List the creation year, name and budget of each department.
Final SQL: SELECT creation ,  name ,  budget_in_billions FROM department
Database: department_management
Question sequence:
List the budget of each department.
What are the maximum and minimum budget of the departments?
SQL query sequence:
SELECT budget_in_billions FROM department
SELECT max(budget_in_billions) ,  min(budget_in_billions) FROM department
Final question: What are the maximum and minimum budget of the departments?
Final SQL: SELECT max(budget_in_billions) ,  min(budget_in_billions) FROM department
Database: department_management
Question sequence:
How many employees does each department have?
What is the number of employees of the departments whose rank is between 10 and 15?
What is the average number of employees of these departments?
SQL query sequence:
SELECT num_employees FROM department
SELECT num_employees FROM department WHERE ranking BETWEEN 10 AND 15
SELECT avg(num_employees) FROM department WHERE ranking BETWEEN 10 AND 15
Final question: What is the average number of employees of the departments whose rank is between 10 and 15?
Final SQL: SELECT avg(num_employees) FROM department WHERE ranking BETWEEN 10 AND 15
Database: department_management
Question sequence:
Show all the names of the department heads.
Among these department heads, who was born outside California?
SQL query sequence:
SELECT name FROM head
SELECT name FROM head WHERE born_state != 'California'
Final question: What are the names of the heads who are born outside the California state?
Final SQL: SELECT name FROM head WHERE born_state != 'California'
Database: department_management
Question sequence:
What are the creation years of the departments?
Which secretaries were born in Alabama?
What are the distinct creation years of the departments managed by a secretary born in state 'Alabama'?
SQL query sequence:
SELECT creation FROM department
SELECT * FROM head WHERE born_state  =  'Alabama'
SELECT DISTINCT T1.creation FROM department AS T1 JOIN management AS T2 ON T1.department_id  =  T2.department_id JOIN head AS T3 ON T2.head_id  =  T3.head_id WHERE T3.born_state  =  'Alabama'
Final question: What are the distinct creation years of the departments managed by a secretary born in state 'Alabama'?
Final SQL: SELECT DISTINCT T1.creation FROM department AS T1 JOIN management AS T2 ON T1.department_id  =  T2.department_id JOIN head AS T3 ON T2.head_id  =  T3.head_id WHERE T3.born_state  =  'Alabama'
Database: department_management
Question sequence:
What are the names of the states where department heads were born?
How many heads were born in each state?
What are the names of the states where at least 3 heads were born?
SQL query sequence:
SELECT born_state FROM head
SELECT born_state, count(*) FROM head GROUP BY born_state
SELECT born_state FROM head GROUP BY born_state HAVING count(*)  >=  3
Final question: What are the names of the states where at least 3 heads were born?
Final SQL: SELECT born_state FROM head GROUP BY born_state HAVING count(*)  >=  3
Database: department_management
Question sequence:
What are the years in which departments were established?
In which year were the most departments established?
SQL query sequence:
SELECT creation FROM department GROUP BY creation
SELECT creation FROM department GROUP BY creation ORDER BY count(*) DESC LIMIT 1
Final question: In which year were most departments established?
Final SQL: SELECT creation FROM department GROUP BY creation ORDER BY count(*) DESC LIMIT 1
Database: department_management
Question sequence:
Show the names and number of employees of each department.
Who are the department heads whose temporary acting value is "Yes"?
Show the name and number of employees for the departments managed by heads whose temporary acting value is 'Yes'.
SQL query sequence:
SELECT name , num_employees FROM department
SELECT * FROM management WHERE temporary_acting  =  'Yes'
SELECT T1.name ,  T1.num_employees FROM department AS T1 JOIN management AS T2 ON T1.department_id  =  T2.department_id WHERE T2.temporary_acting  =  'Yes'
Final question: Show the name and number of employees for the departments managed by heads whose temporary acting value is 'Yes'?
Final SQL: SELECT T1.name ,  T1.num_employees FROM department AS T1 JOIN management AS T2 ON T1.department_id  =  T2.department_id WHERE T2.temporary_acting  =  'Yes'
Database: department_management
Question sequence:
List the acting statuses.
How many acting statuses are there?
SQL query sequence:
SELECT temporary_acting FROM management
SELECT count(DISTINCT temporary_acting) FROM management
Final question: How many acting statuses are there?
Final SQL: SELECT count(DISTINCT temporary_acting) FROM management
Database: department_management
Question sequence:
How many departments are there?
How many departments are led by heads who are mentioned in the database?
How many departments are led by heads who are not mentioned?
SQL query sequence:
SELECT count(*) FROM department
SELECT count(*) FROM department WHERE department_id IN (SELECT department_id FROM management);
SELECT count(*) FROM department WHERE department_id NOT IN (SELECT department_id FROM management);
Final question: How many departments are led by heads who are not mentioned?
Final SQL: SELECT count(*) FROM department WHERE department_id NOT IN (SELECT department_id FROM management);
Database: department_management
Question sequence:
What are the dictinct ages of the department heads?
List the ages of the heads who are acting.
SQL query sequence:
SELECT DISTINCT T1.age FROM management AS T2 JOIN head AS T1 ON T1.head_id  =  T2.head_id
SELECT DISTINCT T1.age FROM management AS T2 JOIN head AS T1 ON T1.head_id  =  T2.head_id WHERE T2.temporary_acting  =  'Yes'
Final question: What are the distinct ages of the heads who are acting?
Final SQL: SELECT DISTINCT T1.age FROM management AS T2 JOIN head AS T1 ON T1.head_id  =  T2.head_id WHERE T2.temporary_acting  =  'Yes'
Database: department_management
Question sequence:
List the states where each secretary was born.
List the information of the secretary of 'Treasury' department and the secretary of 'Homeland Security' department.
List the states where both the secretary of 'Treasury' department and the secretary of 'Homeland Security' were born.
SQL query sequence:
SELECT DISTINCT born_state FROM head
SELECT T3.name, T3.born_state FROM department AS T1 JOIN management AS T2 ON T1.department_id  =  T2.department_id JOIN head AS T3 ON T2.head_id  =  T3.head_id WHERE T1.name  =  'Treasury' or T1.name  =  'Homeland Security'
SELECT T3.born_state FROM department AS T1 JOIN management AS T2 ON T1.department_id  =  T2.department_id JOIN head AS T3 ON T2.head_id  =  T3.head_id WHERE T1.name  =  'Treasury' INTERSECT SELECT T3.born_state FROM department AS T1 JOIN management AS T2 ON T1.department_id  =  T2.department_id JOIN head AS T3 ON T2.head_id  =  T3.head_id WHERE T1.name  =  'Homeland Security'
Final question: List the states where both the secretary of 'Treasury' department and the secretary of 'Homeland Security' were born.
Final SQL: SELECT T3.born_state FROM department AS T1 JOIN management AS T2 ON T1.department_id  =  T2.department_id JOIN head AS T3 ON T2.head_id  =  T3.head_id WHERE T1.name  =  'Treasury' INTERSECT SELECT T3.born_state FROM department AS T1 JOIN management AS T2 ON T1.department_id  =  T2.department_id JOIN head AS T3 ON T2.head_id  =  T3.head_id WHERE T1.name  =  'Homeland Security'
Database: department_management
Question sequence:
How many heads does each department have?
Which department has more than 1 head at a time?
List the id, name and the number of heads of these departments.
SQL query sequence:
SELECT T1.name ,  count(*) FROM management AS T2 JOIN department AS T1 ON T1.department_id  =  T2.department_id GROUP BY T1.department_id
SELECT T1.department_id ,  T1.name FROM management AS T2 JOIN department AS T1 ON T1.department_id  =  T2.department_id GROUP BY T1.department_id HAVING count(*)  >  1
SELECT T1.department_id ,  T1.name ,  count(*) FROM management AS T2 JOIN department AS T1 ON T1.department_id  =  T2.department_id GROUP BY T1.department_id HAVING count(*)  >  1
Final question: Which department has more than 1 head at a time? List the id, name and the number of heads.
Final SQL: SELECT T1.department_id ,  T1.name ,  count(*) FROM management AS T2 JOIN department AS T1 ON T1.department_id  =  T2.department_id GROUP BY T1.department_id HAVING count(*)  >  1
Database: city_record
Question sequence:
How many cities are there
How many cities have hosted events?
Wihch city hosted events in the most recent year?
Show its id.
SQL query sequence:
SELECT COUNT(*) FROM City
SELECT count(DISTINCT city) FROM City as T1 JOIN Hosting_City as T2 on T1.City_ID = T2.Host_City
SELECT T1.City FROM City as T1 JOIN Hosting_City as T2 on T1.City_ID = T2.Host_City ORDER BY YEAR DESC LIMIT 1
SELECT host_city FROM hosting_city ORDER BY YEAR DESC LIMIT 1
Final question: What is id of the city that hosted events in the most recent year?
Final SQL: SELECT host_city FROM hosting_city ORDER BY YEAR DESC LIMIT 1
Database: city_record
Question sequence:
Show the names of the cities.
Which of them were a host city after 2008?
How about the cities that were a host city after 2010?
SQL query sequence:
SELECT City FROM City
SELECT T1.city FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city WHERE T2.year  >  2008
SELECT T1.city FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city WHERE T2.year  >  2010
Final question: Find the cities which were once a host city after 2010?
Final SQL: SELECT T1.city FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city WHERE T2.year  >  2010
Database: city_record
Question sequence:
How many cities have hosted events?
For each city, how many events has it hosted?
Which city has hosted the most events?
SQL query sequence:
SELECT COUNT(DISTINCT city) FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id  =  T2.host_city
SELECT T1.city, COUNT(*) FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id  =  T2.host_city GROUP BY T2.host_city
SELECT T1.city FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id  =  T2.host_city GROUP BY T2.host_city ORDER BY count(*) DESC LIMIT 1
Final question: Which city has hosted the most events?
Final SQL: SELECT T1.city FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id  =  T2.host_city GROUP BY T2.host_city ORDER BY count(*) DESC LIMIT 1
Database: city_record
Question sequence:
How many events has "Nanjing ( Jiangsu )" hosted?
What is the date of the competition "1994 FIFA World Cup qualification" hosted by "Nanjing ( Jiangsu )"?
How about the venue?
SQL query sequence:
SELECT COUNT(*) FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id  =  T2.host_city WHERE City = "Nanjing ( Jiangsu )"
SELECT T3.Date FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city JOIN MATCH AS T3 ON T2.match_id = T3.match_id WHERE T1.city = "Nanjing ( Jiangsu )" AND T3.competition = "1994 FIFA World Cup qualification"
SELECT T3.venue FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city JOIN MATCH AS T3 ON T2.match_id = T3.match_id WHERE T1.city = "Nanjing ( Jiangsu )" AND T3.competition = "1994 FIFA World Cup qualification"
Final question: What is the venue of the competition "1994 FIFA World Cup qualification" hosted by "Nanjing ( Jiangsu )"?
Final SQL: SELECT T3.venue FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city JOIN MATCH AS T3 ON T2.match_id = T3.match_id WHERE T1.city = "Nanjing ( Jiangsu )" AND T3.competition = "1994 FIFA World Cup qualification"
Database: city_record
Question sequence:
How many events has "Shanghai" hosted?
Give me the temperature of Shanghai in March.
How about the temperature in January?
SQL query sequence:
SELECT COUNT(*) FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id  =  T2.host_city WHERE City = "Shanghai"
SELECT T2.Mar FROM city AS T1 JOIN temperature AS T2 ON T1.city_id = T2.city_id WHERE T1.city = "Shanghai"
SELECT T2.Jan FROM city AS T1 JOIN temperature AS T2 ON T1.city_id = T2.city_id WHERE T1.city = "Shanghai"
Final question: Give me the temperature of Shanghai in January.
Final SQL: SELECT T2.Jan FROM city AS T1 JOIN temperature AS T2 ON T1.city_id = T2.city_id WHERE T1.city = "Shanghai"
Database: city_record
Question sequence:
How many events has "Taizhou ( Zhejiang )" hosted?
What event did it host?
What is the host year of this city?
SQL query sequence:
SELECT COUNT(*) FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id  =  T2.host_city WHERE City = "Taizhou ( Zhejiang )"
SELECT T3.Competition FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id  =  T2.host_city JOIN match AS T3 ON T2.MATCH_ID = T3.MATCH_ID WHERE T1.city  =  "Taizhou ( Zhejiang )"
SELECT T2.year FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id  =  T2.host_city WHERE T1.city  =  "Taizhou ( Zhejiang )"
Final question: What is the host year of city "Taizhou ( Zhejiang )"?
Final SQL: SELECT T2.year FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id  =  T2.host_city WHERE T1.city  =  "Taizhou ( Zhejiang )"
Database: city_record
Question sequence:
What is the average regional population?
Which city has the largest regional population?
What are the top three cities with the largest regional population?
SQL query sequence:
SELECT AVG(regional_population) FROM city
SELECT city FROM city ORDER BY regional_population DESC LIMIT 1
SELECT city FROM city ORDER BY regional_population DESC LIMIT 3
Final question: Which three cities have the largest regional population?
Final SQL: SELECT city FROM city ORDER BY regional_population DESC LIMIT 3
Database: city_record
Question sequence:
What is the average GDP among all cities?
What is the minimum GDP?
Please also list the city name.
SQL query sequence:
SELECT AVG(GDP) FROM city
SELECT GDP FROM city ORDER BY GDP LIMIT 1
SELECT city ,  GDP FROM city ORDER BY GDP LIMIT 1
Final question: Which city has the lowest GDP? Please list the city name and its GDP.
Final SQL: SELECT city ,  GDP FROM city ORDER BY GDP LIMIT 1