aherntech/sparc huggingface dataset:
Database: movie_1
Question sequence:
What are all the directors excluding NULL?
What about the highest rating their movies have ever received?
Also give me those movies' title.
SQL query sequence:
SELECT distinct director FROM Movie WHERE director != "null"
SELECT T2.director ,  max(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID  =  T2.mID WHERE director != "null" GROUP BY director
SELECT T2.title ,  T1.stars ,  T2.director ,  max(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID  =  T2.mID WHERE director != "null" GROUP BY director
Final question: For each director, return the director's name together with the title of the movie they directed that received the highest rating among all of their movies, and the value of that rating. Ignore movies whose director is NULL.
Final SQL: SELECT T2.title ,  T2.director ,  max(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID  =  T2.mID WHERE director != "null" GROUP BY director
Database: movie_1
Question sequence:
What are the name of all the reviewers?
What are the least rating stars they ever gave?
Also show me the title of the movies that correspond to those rating stars.
SQL query sequence:
SELECT name from Reviewer
SELECT min(stars) FROM Rating GROUP BY rID
SELECT T2.title ,  T1.rID ,  T1.stars ,  min(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID  =  T2.mID GROUP BY T1.rID
Final question: Find the title and star rating of the movie that got the least rating star for each reviewer.
Final SQL: SELECT T2.title ,  T1.rID ,  T1.stars ,  min(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID  =  T2.mID GROUP BY T1.rID
Database: movie_1
Question sequence:
Who are all the directors?
What about the lowest rating their movies have ever received?
Also give me those movies' title.
SQL query sequence:
SELECT distinct director FROM Movie
SELECT T2.director ,  min(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID  =  T2.mID GROUP BY director
SELECT T2.title ,  T1.stars ,  T2.director ,  min(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID  =  T2.mID GROUP BY T2.director
Final question: Find the title and score of the movie with the lowest rating among all movies directed by each director.
Final SQL: SELECT T2.title ,  T1.stars ,  T2.director ,  min(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID  =  T2.mID GROUP BY T2.director
Database: movie_1
Question sequence:
What are the names of all movies?
How many ratings did each of them have?
Give me the name of the movie that has the most ratings.
SQL query sequence:
SELECT title FROM Movie
SELECT count(*) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID  =  T2.mID GROUP BY t1.mID
SELECT T2.title ,  T1.mID FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID  =  T2.mID GROUP BY T1.mID ORDER BY count(*) DESC LIMIT 1
Final question: What is the name of the movie that is rated by most of times?
Final SQL: SELECT T2.title ,  T1.mID FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID  =  T2.mID GROUP BY T1.mID ORDER BY count(*) DESC LIMIT 1
Database: movie_1
Question sequence:
What are the name of all movies?
What rating star did each of them have?
Give me the movies that have rating star between 3 and 5.
SQL query sequence:
SELECT title FROM Movie
SELECT T2.title, T1.stars FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID  =  T2.mID
SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID  =  T2.mID WHERE T1.stars BETWEEN 3 AND 5
Final question: What are the titles of all movies that have rating star is between 3 and 5?
Final SQL: SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID  =  T2.mID WHERE T1.stars BETWEEN 3 AND 5
Database: movie_1
Question sequence:
What are the names of all the reviewers?
Who had given ratings higher than 3 stars?
SQL query sequence:
SELECT name FROM Reviewer
SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID  =  T2.rID WHERE T1.stars  >  3
Final question: Find the names of reviewers who had given higher than 3 stars ratings.
Final SQL: SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID  =  T2.rID WHERE T1.stars  >  3
Database: movie_1
Question sequence:
What are the name of all the reviewers?
What are the movies that are reviewed by Brittany Harris?
Show me the average rating star for all other movies except those.
SQL query sequence:
SELECT name FROM Reviewer
SELECT T1.mID FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID  =  T2.rID WHERE T2.name  =  "Brittany Harris"
SELECT mID ,  avg(stars) FROM Rating WHERE mID NOT IN (SELECT T1.mID FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID  =  T2.rID WHERE T2.name  =  "Brittany Harris") GROUP BY mID
Final question: Find the average rating star for each movie that are not reviewed by Brittany Harris.
Final SQL: SELECT mID ,  avg(stars) FROM Rating WHERE mID NOT IN (SELECT T1.mID FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID  =  T2.rID WHERE T2.name  =  "Brittany Harris") GROUP BY mID
Database: movie_1
Question sequence:
What are the name of all the reviewers?
What are the ids of the movies that are reviewed by Brittany Harris?
Show me the ids of movies except those.
SQL query sequence:
SELECT name FROM Reviewer
SELECT T1.mID FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID  =  T2.rID WHERE T2.name  =  "Brittany Harris"
SELECT mID FROM Rating EXCEPT SELECT T1.mID FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID  =  T2.rID WHERE T2.name  =  "Brittany Harris"
Final question: What are the ids of the movies that are not reviewed by Brittany Harris.
Final SQL: SELECT mID FROM Rating EXCEPT SELECT T1.mID FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID  =  T2.rID WHERE T2.name  =  "Brittany Harris"
Database: movie_1
Question sequence:
What are the rating star for all the movies?
Give me the average rating star for each movie.
Only show those that received at least 2 ratings.
SQL query sequence:
SELECT mID, stars FROM Rating
SELECT mID ,  avg(stars) FROM Rating GROUP BY mID
SELECT mID ,  avg(stars) FROM Rating GROUP BY mID HAVING count(*)  >=  2
Final question: Find the average rating star for each movie that received at least 2 ratings.
Final SQL: SELECT mID ,  avg(stars) FROM Rating GROUP BY mID HAVING count(*)  >=  2
Database: movie_1
Question sequence:
What are all the ratings?
Show me the ids of reviewers who gave 4 star.
Give me the ids of reviewers except those.
SQL query sequence:
SELECT * FROM Rating
SELECT distinct rID FROM Rating WHERE stars  =  4
SELECT rID FROM Rating EXCEPT SELECT rID FROM Rating WHERE stars  =  4
Final question: find the ids of reviewers who did not give 4 star.
Final SQL: SELECT rID FROM Rating EXCEPT SELECT rID FROM Rating WHERE stars  =  4
Database: movie_1
Question sequence:
Show me the name of all the movies.
What about those that were made after 2000?
Please also include those that were reviewed by Brittany Harris.
SQL query sequence:
SELECT title FROM Movie
SELECT title FROM Movie where year > 2000
SELECT DISTINCT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID  =  T2.mID JOIN Reviewer AS T3 ON T1.rID  =  T3.rID WHERE T3.name  =  'Brittany Harris' OR T2.year  >  2000
Final question: What are names of the movies that are either made after 2000 or reviewed by Brittany Harris?
Final SQL: SELECT DISTINCT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID  =  T2.mID JOIN Reviewer AS T3 ON T1.rID  =  T3.rID WHERE T3.name  =  'Brittany Harris' OR T2.year  >  2000
Database: movie_1
Question sequence:
Show me the name of all the movies.
What about those that were made before 1980?
Please also include those that were directed by James Cameron.
SQL query sequence:
SELECT title FROM Movie
SELECT title FROM Movie where year < 1980
SELECT title FROM Movie WHERE director  =  "James Cameron" OR YEAR   <  1980
Final question: What are names of the movies that are either made before 1980 or directed by James Cameron?
Final SQL: SELECT title FROM Movie WHERE director  =  "James Cameron" OR YEAR   <  1980
Database: movie_1
Question sequence:
Show me the name of all the reviewers.
What about the rating star they had given?
Show me the reviewers who had rated 3 star and 4 star.
SQL query sequence:
SELECT name FROM Reviewer
SELECT T2.name, T1.stars FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID  =  T2.rID
SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID  =  T2.rID WHERE T1.stars  =  3 INTERSECT SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID  =  T2.rID WHERE T1.stars  =  4
Final question: What are the names of reviewers who had rated 3 star and 4 star?
Final SQL: SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID  =  T2.rID WHERE T1.stars  =  3 INTERSECT SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID  =  T2.rID WHERE T1.stars  =  4
Database: epinions_1
Question sequence:
List the ratings for all of the reviews.
What was the average rating?
Include the maximum as well.
SQL query sequence:
SELECT rating FROM review
SELECT avg(rating) FROM review
SELECT avg(rating) ,  max(rating) FROM review
Final question: Find the average and maximum rating of all reviews.
Final SQL: SELECT avg(rating) ,  max(rating) FROM review
Database: epinions_1
Question sequence:
Show all items.
Which ones received reviews?
How about those that did not receive any reviews?
How many unreviewed items were there?
SQL query sequence:
SELECT title FROM item
SELECT title FROM item WHERE i_id IN (SELECT i_id FROM review)
SELECT title FROM item WHERE i_id NOT IN (SELECT i_id FROM review)
SELECT count(*) FROM item WHERE i_id NOT IN (SELECT i_id FROM review)
Final question: Find the number of items that did not receive any review.
Final SQL: SELECT count(*) FROM item WHERE i_id NOT IN (SELECT i_id FROM review)
Database: epinions_1
Question sequence:
List the ratings of all goods.
Include the names of the goods.
How many received a rating of 10?
What are the names of these goods?
SQL query sequence:
SELECT rating FROM review
SELECT T1.title, T2.rating FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id
SELECT count(*) FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id WHERE T2.rating  =  10
SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id WHERE T2.rating  =  10
Final question: Find the names of goods that receive a rating of 10.
Final SQL: SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id WHERE T2.rating  =  10
Database: epinions_1
Question sequence:
What is the average rating of all items?
How many items have a rating lower than the average?
How about higher than the average?
What are the names of those items?
SQL query sequence:
SELECT avg(rating) FROM review
SELECT count(*) FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id WHERE T2.rating  <  (SELECT avg(rating) FROM review)
SELECT count(*) FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id WHERE T2.rating  >  (SELECT avg(rating) FROM review)
SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id WHERE T2.rating  >  (SELECT avg(rating) FROM review)
Final question: Find the titles of items whose rating is higher than the average review rating of all items.
Final SQL: SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id WHERE T2.rating  >  (SELECT avg(rating) FROM review)
Database: epinions_1
Question sequence:
List the title and rating for each item.
Order by increasing rating.
How many received a rating below 5?
What are the names of these items?
SQL query sequence:
SELECT T1.title, T2.rating FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id
SELECT T1.title, T2.rating FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id ORDER BY T2.rating ASC
SELECT count(*) FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id WHERE T2.rating  <  5
SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id WHERE T2.rating  <  5
Final question: Find the titles of items that received any rating below 5.
Final SQL: SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id WHERE T2.rating  <  5
Database: epinions_1
Question sequence:
What is the title and rating for each item?
Which ones received a rating higher than 8?
Out of those items, which ones also received a rating less than 5?
SQL query sequence:
SELECT T1.title, T2.rating FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id
SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id WHERE T2.rating  >  8
SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id WHERE T2.rating  >  8 INTERSECT SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id WHERE T2.rating  <  5
Final question: Find the titles of items that received both a rating higher than 8 and a rating below 5.
Final SQL: SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id WHERE T2.rating  >  8 INTERSECT SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id WHERE T2.rating  <  5
Database: epinions_1
Question sequence:
What items were ranked?
How many have a rank that is greater than 3?
List the names of these items.
Out of these items, which ones also have an average rating that is above 5?
SQL query sequence:
SELECT DISTINCT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id
SELECT count(DISTINCT T1.title) FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id WHERE T2.rank  >  3
SELECT DISTINCT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id WHERE T2.rank  >  3
SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id WHERE T2.rank  >  3 INTERSECT SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id GROUP BY T2.i_id HAVING avg(T2.rating)  >  5
Final question: Find the names of items whose rank is higher than 3 and whose average rating is above 5.
Final SQL: SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id WHERE T2.rank  >  3 INTERSECT SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id GROUP BY T2.i_id HAVING avg(T2.rating)  >  5
Database: epinions_1
Question sequence:
List the names of all items
Show the average rating of each one as well.
Order by increasing average rating.
Which one has the lowest?
SQL query sequence:
SELECT title FROM item
SELECT T1.title, avg(T2.rating) FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id GROUP BY T2.i_id
SELECT T1.title, avg(T2.rating) FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id GROUP BY T2.i_id ORDER BY avg(T2.rating)
SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id GROUP BY T2.i_id ORDER BY avg(T2.rating) LIMIT 1
Final question: Find the name of the item with the lowest average rating.
Final SQL: SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id GROUP BY T2.i_id ORDER BY avg(T2.rating) LIMIT 1
Database: epinions_1
Question sequence:
What are the names of all users?
How many reviews were given by each user?
Order by the number of reviews given, from the greatest to the least.
Who gave the most reviews?
SQL query sequence:
SELECT name FROM useracct
SELECT T1.name, count(*) FROM useracct AS T1 JOIN review AS T2 ON T1.u_id  =  T2.u_id GROUP BY T2.u_id
SELECT T1.name, count(*) FROM useracct AS T1 JOIN review AS T2 ON T1.u_id  =  T2.u_id GROUP BY T2.u_id ORDER BY count(*) DESC
SELECT T1.name FROM useracct AS T1 JOIN review AS T2 ON T1.u_id  =  T2.u_id GROUP BY T2.u_id ORDER BY count(*) DESC LIMIT 1
Final question: Find the name of the user who gives the most reviews.
Final SQL: SELECT T1.name FROM useracct AS T1 JOIN review AS T2 ON T1.u_id  =  T2.u_id GROUP BY T2.u_id ORDER BY count(*) DESC LIMIT 1
Database: epinions_1
Question sequence:
List the name of each item that received a rating.
Include the item ID as well.
Order items by decreasing average rating.
Which item had the highest? Include its ID as well.
SQL query sequence:
SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id GROUP BY T2.i_id
SELECT T1.title, T1.i_id FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id GROUP BY T2.i_id
SELECT T1.title ,  T1.i_id FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id GROUP BY T2.i_id ORDER BY avg(T2.rating) DESC
SELECT T1.title ,  T1.i_id FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id GROUP BY T2.i_id ORDER BY avg(T2.rating) DESC LIMIT 1
Final question: Find the name and id of the item with the highest average rating.
Final SQL: SELECT T1.title ,  T1.i_id FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id GROUP BY T2.i_id ORDER BY avg(T2.rating) DESC LIMIT 1
Database: epinions_1
Question sequence:
Which items have a rank?
Also include their IDs.
Order them by average rank from highest to lowest.
What is the name and ID of the item that received the highest average rank?
SQL query sequence:
SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id GROUP BY T2.i_id
SELECT T1.title, T1.i_id FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id GROUP BY T2.i_id
SELECT T1.title ,  T1.i_id FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id GROUP BY T2.i_id ORDER BY avg(T2.rank)
SELECT T1.title ,  T1.i_id FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id GROUP BY T2.i_id ORDER BY avg(T2.rank) DESC LIMIT 1
Final question: Find the name and id of the good with the highest average rank.
Final SQL: SELECT T1.title ,  T1.i_id FROM item AS T1 JOIN review AS T2 ON T1.i_id  =  T2.i_id GROUP BY T2.i_id ORDER BY avg(T2.rank) DESC LIMIT 1
Database: epinions_1
Question sequence:
List the names of all users.
Only show those who gave reviews.
Include the ratings given by each of them.
Only show their name and the average rating given by each of them.
SQL query sequence:
SELECT name FROM useracct
SELECT DISTINCT T1.name FROM useracct AS T1 JOIN review AS T2 ON T1.u_id  =  T2.u_id
SELECT T1.name, T2.rating FROM useracct AS T1 JOIN review AS T2 ON T1.u_id  =  T2.u_id
SELECT T1.name ,  avg(T2.rating) FROM useracct AS T1 JOIN review AS T2 ON T1.u_id  =  T2.u_id GROUP BY T2.u_id
Final question: For each user, return the name and the average rating of reviews given by them.
Final SQL: SELECT T1.name ,  avg(T2.rating) FROM useracct AS T1 JOIN review AS T2 ON T1.u_id  =  T2.u_id GROUP BY T2.u_id
Database: epinions_1
Question sequence:
What are the names of the users?
How many wrote reviews?
List their names?
Include the number of reviews written by each of them.
SQL query sequence:
SELECT name FROM useracct
SELECT count(DISTINCT T1.name) FROM useracct AS T1 JOIN review AS T2 ON T1.u_id  =  T2.u_id
SELECT DISTINCT T1.name FROM useracct AS T1 JOIN review AS T2 ON T1.u_id  =  T2.u_id
SELECT T1.name ,  count(*) FROM useracct AS T1 JOIN review AS T2 ON T1.u_id  =  T2.u_id GROUP BY T2.u_id
Final question: For each user, find their name and the number of reviews written by them.
Final SQL: SELECT T1.name ,  count(*) FROM useracct AS T1 JOIN review AS T2 ON T1.u_id  =  T2.u_id GROUP BY T2.u_id
Database: epinions_1
Question sequence:
List the names of users who gave ratings.
Include the ratings that they gave as well.
Order by highest to lowest rating.
Who gave the highest rating?
SQL query sequence:
SELECT DISTINCT T1.name FROM useracct AS T1 JOIN review AS T2 ON T1.u_id  =  T2.u_id
SELECT T1.name, T2.rating FROM useracct AS T1 JOIN review AS T2 ON T1.u_id  =  T2.u_id
SELECT T1.name FROM useracct AS T1 JOIN review AS T2 ON T1.u_id  =  T2.u_id ORDER BY T2.rating DESC
SELECT T1.name FROM useracct AS T1 JOIN review AS T2 ON T1.u_id  =  T2.u_id ORDER BY T2.rating DESC LIMIT 1
Final question: Find the name of the user who gave the highest rating.
Final SQL: SELECT T1.name FROM useracct AS T1 JOIN review AS T2 ON T1.u_id  =  T2.u_id ORDER BY T2.rating DESC LIMIT 1
Database: epinions_1
Question sequence:
What are all of the users’ names?
Only show the names of source users.
Order them by decreasing average trust score.
Who has the highest average trust score?
SQL query sequence:
SELECT name FROM useracct
SELECT DISTINCT T1.name FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id  =  T2.source_u_id
SELECT T1.name FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id  =  T2.source_u_id GROUP BY T2.source_u_id ORDER BY avg(trust) DESC
SELECT T1.name FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id  =  T2.source_u_id GROUP BY T2.source_u_id ORDER BY avg(trust) DESC LIMIT 1
Final question: Find the name of the source user with the highest average trust score.
Final SQL: SELECT T1.name FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id  =  T2.source_u_id GROUP BY T2.source_u_id ORDER BY avg(trust) DESC LIMIT 1
Database: epinions_1
Question sequence:
List the names of all target users.
Include the trust scores for each target user.
List the name and average trust score for each target user.
SQL query sequence:
SELECT DISTINCT T1.name FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id  =  T2.target_u_id
SELECT T1.name ,  T2.trust FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id  =  T2.target_u_id
SELECT T1.name ,  avg(trust) FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id  =  T2.target_u_id GROUP BY T2.target_u_id
Final question: Find each target user's name and average trust score.
Final SQL: SELECT T1.name ,  avg(trust) FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id  =  T2.target_u_id GROUP BY T2.target_u_id
Database: epinions_1
Question sequence:
What are the names of all users?
Only show the target users.
Order them by increasing trust score.
Who has the lowest trust score?
SQL query sequence:
SELECT name FROM useracct
SELECT DISTINCT T1.name FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id  =  T2.target_u_id
SELECT T1.name FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id  =  T2.target_u_id ORDER BY trust
SELECT T1.name FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id  =  T2.target_u_id ORDER BY trust LIMIT 1
Final question: Find the name of the target user with the lowest trust score.
Final SQL: SELECT T1.name FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id  =  T2.target_u_id ORDER BY trust LIMIT 1
Database: epinions_1
Question sequence:
List the names of all items.
How many did not receive any reviews?
List their names.
SQL query sequence:
SELECT title FROM item
SELECT count(*) FROM item WHERE i_id NOT IN (SELECT i_id FROM review)
SELECT title FROM item WHERE i_id NOT IN (SELECT i_id FROM review)
Final question: Find the names of the items that did not receive any review.
Final SQL: SELECT title FROM item WHERE i_id NOT IN (SELECT i_id FROM review)
Database: epinions_1
Question sequence:
What are all of the users’ names?
How many wrote reviews?
How many did not write reviews?
List their names.
SQL query sequence:
SELECT name FROM useracct
SELECT count(*) FROM useracct WHERE u_id IN (SELECT u_id FROM review)
SELECT count(*) FROM useracct WHERE u_id NOT IN (SELECT u_id FROM review)
SELECT name FROM useracct WHERE u_id NOT IN (SELECT u_id FROM review)
Final question: Find the names of users who did not leave any review.
Final SQL: SELECT name FROM useracct WHERE u_id NOT IN (SELECT u_id FROM review)
Database: customer_complaints
Question sequence:
Which cities have customer_type_code of "Good Credit Rating"?
Which ones do not?
Give the counts of the town city groups of customers in that first query.
Just return the town city with the least number.
SQL query sequence:
SELECT DISTINCT town_city FROM customers WHERE customer_type_code  =  "Good Credit Rating"
SELECT DISTINCT town_city FROM customers WHERE customer_type_code  !=  "Good Credit Rating"
SELECT town_city, count(*) FROM customers WHERE customer_type_code  =  "Good Credit Rating" GROUP BY town_city
SELECT town_city FROM customers WHERE customer_type_code  =  "Good Credit Rating" GROUP BY town_city ORDER BY count(*) LIMIT 1
Final question: Which city has the least number of customers whose type code is "Good Credit Rating"?
Final SQL: SELECT town_city FROM customers WHERE customer_type_code  =  "Good Credit Rating" GROUP BY town_city ORDER BY count(*) LIMIT 1