aherntech/sparc huggingface dataset:
Database: twitter_1
Question sequence:
How many tweets are there?
Among these tweets, how many of them are about the topic 'intern'?
Please show their texts.
SQL query sequence:
SELECT COUNT(*) FROM tweets
SELECT COUNT(*) FROM tweets WHERE text LIKE '%intern%'
SELECT text FROM tweets WHERE text LIKE '%intern%'
Final question: Return the text of tweets about the topic 'intern'.
Final SQL: SELECT text FROM tweets WHERE text LIKE '%intern%'
Database: twitter_1
Question sequence:
How many followers does the user named "Tyler Swift" have?
How many users are there whose number of followers is greater than that of the user named "Tyler Swift"?
Show the names of these users.
SQL query sequence:
SELECT count(*) FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid  =  T2.f1 WHERE T1.name  =  'Tyler Swift'
SELECT COUNT(*) FROM (SELECT T1.name FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid  =  T2.f1 GROUP BY T2.f1 HAVING count(*)  >  (SELECT count(*) FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid  =  T2.f1 WHERE T1.name  =  'Tyler Swift'))
SELECT T1.name FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid  =  T2.f1 GROUP BY T2.f1 HAVING count(*)  >  (SELECT count(*) FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid  =  T2.f1 WHERE T1.name  =  'Tyler Swift')
Final question: Find the names of the users whose number of followers is greater than that of the user named "Tyler Swift".
Final SQL: SELECT T1.name FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid  =  T2.f1 GROUP BY T2.f1 HAVING count(*)  >  (SELECT count(*) FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid  =  T2.f1 WHERE T1.name  =  'Tyler Swift')
Database: twitter_1
Question sequence:
Who has the least number of followers?
How many users have more than one follower?
Show their names and emails.
SQL query sequence:
SELECT Name FROM user_profiles ORDER BY followers LIMIT 1
SELECT COUNT(*) FROM (SELECT T1.name FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid  =  T2.f1 GROUP BY T2.f1 HAVING count(*)  >  1)
SELECT T1.name ,  T1.email FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid  =  T2.f1 GROUP BY T2.f1 HAVING count(*)  >  1
Final question: Find the name and email for the users who have more than one follower.
Final SQL: SELECT T1.name ,  T1.email FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid  =  T2.f1 GROUP BY T2.f1 HAVING count(*)  >  1
Database: twitter_1
Question sequence:
How many tweets are there?
What is the text of the tweet with id 1?
How many tweets does each user have?
Who has more than one tweet?
SQL query sequence:
SELECT COUNT(*) FROM tweets
SELECT text FROM tweets WHERE id = 1
SELECT T1.name, COUNT(*) FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid  =  T2.uid GROUP BY T2.uid
SELECT T1.name FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid  =  T2.uid GROUP BY T2.uid HAVING count(*)  >  1
Final question: Find the names of users who have more than one tweet.
Final SQL: SELECT T1.name FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid  =  T2.uid GROUP BY T2.uid HAVING count(*)  >  1
Database: twitter_1
Question sequence:
How many followers does Mary have?
How about that of Susan?
Who is followed by either one of them?
What are their ids?
SQL query sequence:
SELECT Followers FROM user_profiles WHERE name  =  "Mary"
SELECT Followers FROM user_profiles WHERE name  =  "Susan"
SELECT T3.NAME FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid  =  T2.f2 JOIN user_profiles AS T3 ON T3.uid = T2.f1 WHERE T1.name  =  "Mary" OR T1.name  =  "Susan"
SELECT T2.f1 FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid  =  T2.f2 WHERE T1.name  =  "Mary" OR T1.name  =  "Susan"
Final question: Find the id of users who are followed by Mary or Susan.
Final SQL: SELECT T2.f1 FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid  =  T2.f2 WHERE T1.name  =  "Mary" OR T1.name  =  "Susan"
Database: twitter_1
Question sequence:
Who has the most followers?
What is the minimum number of followers of all users?
Please show the name of the user with that number of followers.
Please also show the email.
SQL query sequence:
SELECT name FROM user_profiles ORDER BY followers DESC LIMIT 1
SELECT followers FROM user_profiles ORDER BY followers LIMIT 1
SELECT name FROM user_profiles ORDER BY followers LIMIT 1
SELECT name ,  email FROM user_profiles ORDER BY followers LIMIT 1
Final question: Find the name and email of the user followed by the least number of people.
Final SQL: SELECT name ,  email FROM user_profiles ORDER BY followers LIMIT 1
Database: twitter_1
Question sequence:
How many followers does each user have?
Who has the most followers?
Which top 5 users have the most followers?
SQL query sequence:
SELECT name, followers FROM user_profiles
SELECT name FROM user_profiles ORDER BY followers DESC LIMIT 1
SELECT name FROM user_profiles ORDER BY followers DESC LIMIT 5
Final question: List the names of 5 users followed by the largest number of other users.
Final SQL: SELECT name FROM user_profiles ORDER BY followers DESC LIMIT 5
Database: twitter_1
Question sequence:
How many users are there?
Show their names.
Please also show the number of tweets tweeted by each of them.
SQL query sequence:
SELECT COUNT(*) FROM user_profiles
SELECT Name FROM user_profiles
SELECT T1.name ,  count(*) FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid  =  T2.uid GROUP BY T2.uid
Final question: Find the name of each user and number of tweets tweeted by each of them.
Final SQL: SELECT T1.name ,  count(*) FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid  =  T2.uid GROUP BY T2.uid
Database: twitter_1
Question sequence:
How many users tweeted less than twice?
Show their names.
Please also show their partition id
SQL query sequence:
SELECT COUNT(*) FROM (SELECT count(*) FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid  =  T2.uid GROUP BY T2.uid HAVING count(*) <  2)
SELECT T1.name FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid  =  T2.uid GROUP BY T2.uid HAVING count(*)  <  2
SELECT T1.name ,  T1.partitionid FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid  =  T2.uid GROUP BY T2.uid HAVING count(*)  <  2
Final question: Find the name and partition id for users who tweeted less than twice.
Final SQL: SELECT T1.name ,  T1.partitionid FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid  =  T2.uid GROUP BY T2.uid HAVING count(*)  <  2
Database: twitter_1
Question sequence:
How many users have some tweets?
How about the number of users that have tweeted more than once?
Show their names and number of tweets tweeted by them.
SQL query sequence:
SELECT COUNT(*) FROM user_profiles WHERE UID IN (SELECT UID FROM tweets)
SELECT COUNT(*) FROM (SELECT count(*) FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid  =  T2.uid GROUP BY T2.uid HAVING count(*)  >  1)
SELECT T1.name ,  count(*) FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid  =  T2.uid GROUP BY T2.uid HAVING count(*)  >  1
Final question: Find the name of the user who tweeted more than once, and number of tweets tweeted by them.
Final SQL: SELECT T1.name ,  count(*) FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid  =  T2.uid GROUP BY T2.uid HAVING count(*)  >  1
Database: twitter_1
Question sequence:
How many users have some tweets?
Show the name of these users and their number of followers.
What is the average number of followers for these users?
SQL query sequence:
SELECT COUNT(*) FROM user_profiles WHERE UID IN (SELECT UID FROM tweets)
SELECT Name, followers FROM user_profiles WHERE UID IN (SELECT UID FROM tweets)
SELECT avg(followers) FROM user_profiles WHERE UID IN (SELECT UID FROM tweets)
Final question: Find the average number of followers for the users who had some tweets.
Final SQL: SELECT avg(followers) FROM user_profiles WHERE UID IN (SELECT UID FROM tweets)
Database: tracking_orders
Question sequence:
What is the id of the customer who made the most recent order?
What's its status?
What's its id?
SQL query sequence:
SELECT customer_id FROM orders ORDER BY date_order_placed DESC LIMIT 1
SELECT order_status FROM orders ORDER BY date_order_placed DESC LIMIT 1
SELECT order_id FROM orders ORDER BY date_order_placed DESC LIMIT 1
Final question: What is the id of the most recent order?
Final SQL: SELECT order_id FROM orders ORDER BY date_order_placed DESC LIMIT 1
Database: tracking_orders
Question sequence:
When was the oldest order placed?
What's the id of the customer who placed it?
What's the id of the order?
Show me both id's.
SQL query sequence:
SELECT date_order_placed FROM orders ORDER BY date_order_placed LIMIT 1
SELECT customer_id FROM orders ORDER BY date_order_placed LIMIT 1
SELECT order_id FROM orders ORDER BY date_order_placed LIMIT 1
SELECT order_id ,  customer_id FROM orders ORDER BY date_order_placed LIMIT 1
Final question: what are the order id and customer id of the oldest order?
Final SQL: SELECT order_id ,  customer_id FROM orders ORDER BY date_order_placed LIMIT 1
Database: tracking_orders
Question sequence:
Show me all the orders with status "Packing"
Who made those orders?
Show me the distinct customer names.
SQL query sequence:
SELECT * FROM orders WHERE order_status = "Packing"
SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Packing"
SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Packing"
Final question: List the name of all the distinct customers who have orders with status "Packing".
Final SQL: SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Packing"
Database: tracking_orders
Question sequence:
Show me all the orders with status "On Road"
Who made those orders?
Show me the distinct customer names.
SQL query sequence:
SELECT * FROM orders WHERE order_status = "On Road"
SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road"
SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road"
Final question: Find the details of all the distinct customers who have orders with status "On Road".
Final SQL: SELECT DISTINCT T1.customer_details FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road"
Database: tracking_orders
Question sequence:
What is the id of the customer who has the most orders?
Show me details
Show me his or her name.
SQL query sequence:
SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
SELECT T1.customer_details FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
SELECT T1.customer_name FROM customers AS T1 JOIN orders 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 name of the customer who has the most orders?
Final SQL: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
Database: tracking_orders
Question sequence:
What is the name of the customer who has the most orders?
What's his or her id?
SQL query sequence:
SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
SELECT T1.customer_id FROM customers AS T1 JOIN orders 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 id of the customer who has the most orders?
Final SQL: SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
Database: tracking_orders
Question sequence:
Any customer named Jeramie?
Show me the status of his orders
Show me the id's of his orders as well.
SQL query sequence:
SELECT * FROM Customers WHERE customer_name = "Jeramie"
SELECT T2.order_status FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.customer_name = "Jeramie"
SELECT T2.order_id, T2.order_status FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.customer_name = "Jeramie"
Final question: Give me a list of id and status of orders which belong to the customer named "Jeramie".
Final SQL: SELECT T2.order_id ,  T2.order_status FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.customer_name = "Jeramie"
Database: tracking_orders
Question sequence:
Any customer named Jeramie?
Show me the status of his orders
Now show me the dates of those orders.
SQL query sequence:
SELECT * FROM Customers WHERE customer_name = "Jeramie"
SELECT T2.order_status FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.customer_name = "Jeramie"
SELECT T2.date_order_placed FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.customer_name = "Jeramie"
Final question: Find the dates of orders which belong to the customer named "Jeramie".
Final SQL: SELECT T2.date_order_placed FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.customer_name = "Jeramie"
Database: tracking_orders
Question sequence:
Show me the orders placed between 2009-01-01 and 2010-01-01.
Show me the customers who made those orders.
SQL query sequence:
SELECT * FROM orders WHERE date_order_placed >= "2009-01-01" AND date_order_placed <= "2010-01-01"
SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.date_order_placed >= "2009-01-01" AND T2.date_order_placed <= "2010-01-01"
Final question: Give me the names of customers who have placed orders between 2009-01-01 and 2010-01-01.
Final SQL: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.date_order_placed >= "2009-01-01" AND T2.date_order_placed <= "2010-01-01"
Database: tracking_orders
Question sequence:
Show me the orders placed between 1975-01-01 and 1976-01-01.
Show me the product ids of those orders.
SQL query sequence:
SELECT * FROM orders WHERE date_order_placed >= "1975-01-01" AND date_order_placed <= "1976-01-01"
SELECT DISTINCT T2.product_id FROM orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id WHERE T1.date_order_placed >= "1975-01-01" AND T1.date_order_placed <= "1976-01-01"
Final question: Give me a list of distinct product ids from orders placed between 1975-01-01 and 1976-01-01?
Final SQL: SELECT DISTINCT T2.product_id FROM orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id WHERE T1.date_order_placed >= "1975-01-01" AND T1.date_order_placed <= "1976-01-01"
Database: tracking_orders
Question sequence:
Find me customers who have order status "On Road".
Now find me customers who have order status "Shipped".
Now show me customers with both of those order statuses.
SQL query sequence:
SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road"
SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Shipped"
SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road" INTERSECT SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Shipped"
Final question: Find the names of the customers who have order status both "On Road" and "Shipped".
Final SQL: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road" INTERSECT SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Shipped"
Database: tracking_orders
Question sequence:
Find me ids of customers who have order status "On Road".
Now find me ids of customers who have order status "Shipped".
Now show me ids of customers with both of those order statuses.
SQL query sequence:
SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road"
SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Shipped"
SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road" INTERSECT SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Shipped"
Final question: Find the id of the customers who have order status both "On Road" and "Shipped".
Final SQL: SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road" INTERSECT SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Shipped"
Database: tracking_orders
Question sequence:
Show me the order with shipment tracking number 3452.
When was that order placed?
SQL query sequence:
SELECT * FROM orders AS T1 JOIN shipments AS T2 ON T1.order_id = T2.order_id WHERE shipment_tracking_number = 3452
SELECT T1.date_order_placed FROM orders AS T1 JOIN shipments AS T2 ON T1.order_id = T2.order_id WHERE T2.shipment_tracking_number = 3452
Final question: When was the order placed whose shipment tracking number is 3452? Give me the date.
Final SQL: SELECT T1.date_order_placed FROM orders AS T1 JOIN shipments AS T2 ON T1.order_id = T2.order_id WHERE T2.shipment_tracking_number = 3452
Database: tracking_orders
Question sequence:
Show me the order with invoice number 10.
When was that order placed? Give me the date.
SQL query sequence:
SELECT * FROM orders AS T1 JOIN shipments AS T2 ON T1.order_id = T2.order_id WHERE invoice_number = 10
SELECT T1.date_order_placed FROM orders AS T1 JOIN shipments AS T2 ON T1.order_id = T2.order_id WHERE T2.invoice_number = 10
Final question: What is the placement date of the order whose invoice number is 10?
Final SQL: SELECT T1.date_order_placed FROM orders AS T1 JOIN shipments AS T2 ON T1.order_id = T2.order_id WHERE T2.invoice_number = 10
Database: tracking_orders
Question sequence:
Show me all the products.
Show me only the products that have been ordered.
Show me only the count and id of each product
SQL query sequence:
SELECT * FROM Products
SELECT * FROM orders AS T1 JOIN order_items AS T2 JOIN products AS T3 ON T1.order_id = T2.order_id AND T2.product_id = T3.product_id GROUP BY T3.product_id
SELECT count(*) ,  T3.product_id FROM orders AS T1 JOIN order_items AS T2 JOIN products AS T3 ON T1.order_id = T2.order_id AND T2.product_id = T3.product_id GROUP BY T3.product_id
Final question: List the count and id of each product in all the orders.
Final SQL: SELECT count(*) ,  T3.product_id FROM orders AS T1 JOIN order_items AS T2 JOIN products AS T3 ON T1.order_id = T2.order_id AND T2.product_id = T3.product_id GROUP BY T3.product_id
Database: tracking_orders
Question sequence:
Show me all the products.
Show me only the products that have been ordered.
Show me only the name and count of each product
SQL query sequence:
SELECT * FROM Products
SELECT * FROM orders AS T1 JOIN order_items AS T2 JOIN products AS T3 ON T1.order_id = T2.order_id AND T2.product_id = T3.product_id GROUP BY T3.product_id
SELECT T3.product_name ,  count(*) FROM orders AS T1 JOIN order_items AS T2 JOIN products AS T3 ON T1.order_id = T2.order_id AND T2.product_id = T3.product_id GROUP BY T3.product_id
Final question: List the name and count of each product in all orders.
Final SQL: SELECT T3.product_name ,  count(*) FROM orders AS T1 JOIN order_items AS T2 JOIN products AS T3 ON T1.order_id = T2.order_id AND T2.product_id = T3.product_id GROUP BY T3.product_id
Database: tracking_orders
Question sequence:
Show me the 10 most recently shipped orders.
Ok, show me only the most recent one.
Show me its id.
SQL query sequence:
SELECT * FROM shipments ORDER BY shipment_date DESC LIMIT 10
SELECT * FROM shipments ORDER BY shipment_date DESC LIMIT 1
SELECT order_id FROM shipments WHERE shipment_date  =  (SELECT max(shipment_date) FROM shipments)
Final question: Find the id of the order which is shipped most recently.
Final SQL: SELECT order_id FROM shipments WHERE shipment_date  =  (SELECT max(shipment_date) FROM shipments)
Database: tracking_orders
Question sequence:
Who ordered the order with most items?
What is its order id?
SQL query sequence:
SELECT T1.customer_id FROM orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id GROUP BY T1.order_id ORDER BY count(*) DESC LIMIT 1
SELECT T1.order_id FROM orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id GROUP BY T1.order_id ORDER BY count(*) DESC LIMIT 1
Final question: What is the id of the order which has the most items?
Final SQL: SELECT T1.order_id FROM orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id GROUP BY T1.order_id ORDER BY count(*) DESC LIMIT 1
Database: tracking_orders
Question sequence:
What is the id of the order with the most items?
What is the id of the customer who ordered it?
SQL query sequence:
SELECT T1.order_id FROM orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id GROUP BY T1.order_id ORDER BY count(*) DESC LIMIT 1
SELECT T1.customer_name FROM customers AS T1 JOIN orders 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 name of the customer who has the largest number of orders?
Final SQL: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
Database: tracking_orders
Question sequence:
Show me all the dates between 1989-09-03 and 2007-12-25 that invoice number was created.
Sorry, I meant dates before 1989-09-03 and after 2007-12-25.
Now show me their invoice numbers.
SQL query sequence:
SELECT invoice_date FROM invoices WHERE invoice_date > "1989-09-03" AND invoice_date < "2007-12-25"
SELECT invoice_date FROM invoices WHERE invoice_date < "1989-09-03" OR invoice_date > "2007-12-25"
SELECT invoice_number FROM invoices WHERE invoice_date < "1989-09-03" OR invoice_date > "2007-12-25"
Final question: Find the invoice numbers which are created before 1989-09-03 or after 2007-12-25.
Final SQL: SELECT invoice_number FROM invoices WHERE invoice_date < "1989-09-03" OR invoice_date > "2007-12-25"
Database: tracking_orders
Question sequence:
Show me all the details of invoices created between 1989-09-03 and 2007-12-25.
Now show me the distinct details of all the other invoices.
SQL query sequence:
SELECT invoice_date FROM invoices WHERE invoice_date > "1989-09-03" AND invoice_date < "2007-12-25"
SELECT DISTINCT invoice_details FROM invoices WHERE invoice_date < "1989-09-03" OR invoice_date > "2007-12-25"
Final question: Find the distinct details of invoices which are created before 1989-09-03 or after 2007-12-25.
Final SQL: SELECT DISTINCT invoice_details FROM invoices WHERE invoice_date < "1989-09-03" OR invoice_date > "2007-12-25"
Database: tracking_orders
Question sequence:
Show me the names of all customers who have at least two orders.
Show me the number of orders each of them made as well.
SQL query sequence:
SELECT T2.customer_name FROM orders AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.customer_id HAVING count(*)  >=  2
SELECT T2.customer_name ,  count(*) FROM orders AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.customer_id HAVING count(*)  >=  2
Final question: For each customer who has at least two orders, find the customer name and number of orders made.
Final SQL: SELECT T2.customer_name ,  count(*) FROM orders AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.customer_id HAVING count(*)  >=  2