aherntech/sparc huggingface dataset:
Database: singer
Question sequence:
Show the songs and sale amounts.
Show the names of singers and the total sales of their songs.
SQL query sequence:
SELECT title, Sales from song
SELECT T1.Name ,  sum(T2.Sales) FROM singer AS T1 JOIN song AS T2 ON T1.Singer_ID  =  T2.Singer_ID GROUP BY T1.Name
Final question: Show the names of singers and the total sales of their songs.
Final SQL: SELECT T1.Name ,  sum(T2.Sales) FROM singer AS T1 JOIN song AS T2 ON T1.Singer_ID  =  T2.Singer_ID GROUP BY T1.Name
Database: singer
Question sequence:
Which singer ids have at least one song?
Which singer names do not?
SQL query sequence:
SELECT DISTINCT Singer_ID from song
SELECT Name FROM singer WHERE Singer_ID NOT IN (SELECT Singer_ID FROM song)
Final question: List the name of singers that do not have any song.
Final SQL: SELECT Name FROM singer WHERE Singer_ID NOT IN (SELECT Singer_ID FROM song)
Database: employee_hire_evaluation
Question sequence:
find all employees who are under age 30.
Which cities did they come from?
show the cities from which more than one employee originated.
SQL query sequence:
SELECT * FROM employee WHERE age  <  30
SELECT city FROM employee WHERE age  <  30
SELECT city FROM employee WHERE age  <  30 GROUP BY city HAVING count(*)  >  1
Final question: Which cities do more than one employee under age 30 come from?
Final SQL: SELECT city FROM employee WHERE age  <  30 GROUP BY city HAVING count(*)  >  1
Database: employee_hire_evaluation
Question sequence:
show all shops.
what is the total number of products they are selling?
find the name of the shop with the greatest number of products.
what are its manager name and district?
SQL query sequence:
SELECT * FROM shop
SELECT sum(number_products) FROM shop
SELECT name FROM shop ORDER BY number_products DESC LIMIT 1
SELECT manager_name ,  district FROM shop ORDER BY number_products DESC LIMIT 1
Final question: Find the manager name and district of the shop whose number of products is the largest.
Final SQL: SELECT manager_name ,  district FROM shop ORDER BY number_products DESC LIMIT 1
Database: employee_hire_evaluation
Question sequence:
find the average number of products of all stores.
how about the minimum and maximum?
SQL query sequence:
SELECT avg(Number_products) FROM shop
SELECT min(Number_products) ,  max(Number_products) FROM shop
Final question: find the minimum and maximum number of products of all stores.
Final SQL: SELECT min(Number_products) ,  max(Number_products) FROM shop
Database: employee_hire_evaluation
Question sequence:
show the name and number of product for all shops.
what is the average number of products?
Find the names of stores whose number products is less than the average.
how about more than?
SQL query sequence:
SELECT name, number_products FROM shop
SELECT avg(number_products) FROM shop
SELECT name FROM shop WHERE number_products  <  (SELECT avg(number_products) FROM shop)
SELECT name FROM shop WHERE number_products  >  (SELECT avg(number_products) FROM shop)
Final question: Find the names of stores whose number products is more than the average number of products.
Final SQL: SELECT name FROM shop WHERE number_products  >  (SELECT avg(number_products) FROM shop)
Database: employee_hire_evaluation
Question sequence:
how many evaluations are there?
what years were they given?
find the name of the employee who received the most evaluation awards.
SQL query sequence:
SELECT count(*) FROM evaluation
SELECT Year_awarded FROM evaluation
SELECT t1.name FROM employee AS t1 JOIN evaluation AS t2 ON t1.Employee_ID  =  t2.Employee_ID GROUP BY t2.Employee_ID ORDER BY count(*) DESC LIMIT 1
Final question: find the name of employee who was awarded the most times in the evaluation.
Final SQL: SELECT t1.name FROM employee AS t1 JOIN evaluation AS t2 ON t1.Employee_ID  =  t2.Employee_ID GROUP BY t2.Employee_ID ORDER BY count(*) DESC LIMIT 1
Database: employee_hire_evaluation
Question sequence:
find the name of the employees who received past evaluation awards.
who won the most times?
ok, which one received the award with the highest bonus?
SQL query sequence:
SELECT t1.name FROM employee AS t1 JOIN evaluation AS t2 ON t1.Employee_ID  =  t2.Employee_ID
SELECT t1.name FROM employee AS t1 JOIN evaluation AS t2 ON t1.Employee_ID  =  t2.Employee_ID GROUP BY T2.Employee_ID ORDER BY COUNT(*) DESC LIMIT 1
SELECT t1.name FROM employee AS t1 JOIN evaluation AS t2 ON t1.Employee_ID  =  t2.Employee_ID ORDER BY t2.bonus DESC LIMIT 1
Final question: Find the name of the employee who got the highest one time bonus.
Final SQL: SELECT t1.name FROM employee AS t1 JOIN evaluation AS t2 ON t1.Employee_ID  =  t2.Employee_ID ORDER BY t2.bonus DESC LIMIT 1
Database: employee_hire_evaluation
Question sequence:
find the number of different employees who were awarded in the past evaluations.
what are their names?
show the names of the employees who never won.
SQL query sequence:
SELECT count(distinct Employee_ID) FROM evaluation
SELECT t1.name FROM employee AS t1 JOIN evaluation AS t2 ON t1.Employee_ID  =  t2.Employee_ID
SELECT name FROM employee WHERE Employee_ID NOT IN (SELECT Employee_ID FROM evaluation)
Final question: Find the names of employees who never won any award in the evaluation.
Final SQL: SELECT name FROM employee WHERE Employee_ID NOT IN (SELECT Employee_ID FROM evaluation)
Database: employee_hire_evaluation
Question sequence:
how many shops are hiring?
what are the shops' names?'
which one is hiring the largest number of employees?
SQL query sequence:
SELECT count(distinct Shop_ID) FROM hiring
SELECT t2.name FROM hiring AS t1 JOIN shop AS t2 ON t1.shop_id  =  t2.shop_id
SELECT t2.name FROM hiring AS t1 JOIN shop AS t2 ON t1.shop_id  =  t2.shop_id GROUP BY t1.shop_id ORDER BY count(*) DESC LIMIT 1
Final question: What is the name of the shop that is hiring the largest number of employees?
Final SQL: SELECT t2.name FROM hiring AS t1 JOIN shop AS t2 ON t1.shop_id  =  t2.shop_id GROUP BY t1.shop_id ORDER BY count(*) DESC LIMIT 1
Database: employee_hire_evaluation
Question sequence:
show all hiring info.
Find the names of any shops not hiring.
SQL query sequence:
SELECT * FROM hiring
SELECT name FROM shop WHERE shop_id NOT IN (SELECT shop_id FROM hiring)
Final question: Find the name of the shops that do not hire any employee.
Final SQL: SELECT name FROM shop WHERE shop_id NOT IN (SELECT shop_id FROM hiring)
Database: employee_hire_evaluation
Question sequence:
how many employees are being hired in all shops?
show the number for each shop. show the shop name as well.
SQL query sequence:
SELECT count(*) FROM hiring
SELECT count(*) ,  t2.name FROM hiring AS t1 JOIN shop AS t2 ON t1.shop_id  =  t2.shop_id GROUP BY t2.name
Final question: Find the number of employees hired in each shop; show the shop name as well.
Final SQL: SELECT count(*) ,  t2.name FROM hiring AS t1 JOIN shop AS t2 ON t1.shop_id  =  t2.shop_id GROUP BY t2.name
Database: museum_visit
Question sequence:
show all visitors.
order them by their membership level from high to low.
just show their names.
do not list those whose membership level is lower than or equal to 4.
SQL query sequence:
SELECT * FROM visitor
SELECT * FROM visitor ORDER BY Level_of_membership DESC
SELECT name FROM visitor ORDER BY Level_of_membership DESC
SELECT name FROM visitor WHERE Level_of_membership  >  4 ORDER BY Level_of_membership DESC
Final question: Find the names of the visitors whose membership level is higher than 4, and order the results by the level from high to low.
Final SQL: SELECT name FROM visitor WHERE Level_of_membership  >  4 ORDER BY Level_of_membership DESC
Database: museum_visit
Question sequence:
find the number of visitors with a membership level higher than 4.
what are their names and membership levels?
sort by their age from old to young.
SQL query sequence:
SELECT count(*) FROM visitor WHERE Level_of_membership  >  4
SELECT name ,  Level_of_membership FROM visitor WHERE Level_of_membership  >  4
SELECT name ,  Level_of_membership FROM visitor WHERE Level_of_membership  >  4 ORDER BY age DESC
Final question: Find the name and membership level of the visitors whose membership level is higher than 4, and sort by their age from old to young.
Final SQL: SELECT name ,  Level_of_membership FROM visitor WHERE Level_of_membership  >  4 ORDER BY age DESC
Database: museum_visit
Question sequence:
how many museums are in the table?
what is the average number of staff working in these museums?
Find the name of the museum that has the most staff members.
what is its id?
SQL query sequence:
SELECT count(*) FROM museum
SELECT avg(num_of_staff) FROM museum
SELECT name FROM museum ORDER BY num_of_staff DESC LIMIT 1
SELECT museum_id FROM museum ORDER BY num_of_staff DESC LIMIT 1
Final question: Find the id and name of the museum that has the most staff members?
Final SQL: SELECT museum_id ,  name FROM museum ORDER BY num_of_staff DESC LIMIT 1
Database: museum_visit
Question sequence:
find the names of museums opened before 2010.
how about after?
find the minimum number of staff of those museums.
find the names of museums which have more staff than that.
SQL query sequence:
SELECT name FROM museum WHERE open_year  <  2010
SELECT name FROM museum WHERE open_year  >  2010
SELECT min(num_of_staff) FROM museum WHERE open_year  >  2010
SELECT name FROM museum WHERE num_of_staff  >  (SELECT min(num_of_staff) FROM museum WHERE open_year  >  2010)
Final question: find the names of museums which have more staff than the minimum staff number of all museums opened after 2010.
Final SQL: SELECT name FROM museum WHERE num_of_staff  >  (SELECT min(num_of_staff) FROM museum WHERE open_year  >  2010)
Database: museum_visit
Question sequence:
find the names of visitors who visited and who have some museum visit records.
which of them visited some museums more than once?
also show their ids and ages.
SQL query sequence:
SELECT t1.name FROM visitor AS t1 JOIN visit AS t2 ON t1.id  =  t2.visitor_id
SELECT t1.name FROM visitor AS t1 JOIN visit AS t2 ON t1.id  =  t2.visitor_id GROUP BY t1.id HAVING count(*)  >  1
SELECT t1.id ,  t1.name ,  t1.age FROM visitor AS t1 JOIN visit AS t2 ON t1.id  =  t2.visitor_id GROUP BY t1.id HAVING count(*)  >  1
Final question: find the id, name and age for visitors who visited some museums more than once.
Final SQL: SELECT t1.id ,  t1.name ,  t1.age FROM visitor AS t1 JOIN visit AS t2 ON t1.id  =  t2.visitor_id GROUP BY t1.id HAVING count(*)  >  1
Database: museum_visit
Question sequence:
what is the total spent on all visits?
find the name of the visitor who has spent the most money for his or her visits.
what are his id and membership level?
SQL query sequence:
SELECT sum(Total_spent) FROM visit
SELECT t1.name FROM visitor AS t1 JOIN visit AS t2 ON t1.id  =  t2.visitor_id GROUP BY t2.visitor_id ORDER BY sum(t2.Total_spent) DESC LIMIT 1
SELECT t2.visitor_id ,  t1.name ,  t1.Level_of_membership FROM visitor AS t1 JOIN visit AS t2 ON t1.id  =  t2.visitor_id GROUP BY t2.visitor_id ORDER BY sum(t2.Total_spent) DESC LIMIT 1
Final question: What are the id, name and membership level of visitors who have spent the largest amount of money in total in all museum tickets?
Final SQL: SELECT t2.visitor_id ,  t1.name ,  t1.Level_of_membership FROM visitor AS t1 JOIN visit AS t2 ON t1.id  =  t2.visitor_id GROUP BY t2.visitor_id ORDER BY sum(t2.Total_spent) DESC LIMIT 1
Database: museum_visit
Question sequence:
show the id and name of all museums.
show the number of tickets sold for each of them.
which one was visited the most times?
SQL query sequence:
SELECT Museum_ID, name FROM museum
SELECT t2.Museum_ID ,  t1.name, count(*) FROM museum AS t1 JOIN visit AS t2 ON t1.Museum_ID  =  t2.Museum_ID GROUP BY t2.Museum_ID
SELECT t2.Museum_ID ,  t1.name FROM museum AS t1 JOIN visit AS t2 ON t1.Museum_ID  =  t2.Museum_ID GROUP BY t2.Museum_ID ORDER BY count(*) DESC LIMIT 1
Final question: What are the id and name of the museum visited most times?
Final SQL: SELECT t2.Museum_ID ,  t1.name FROM museum AS t1 JOIN visit AS t2 ON t1.Museum_ID  =  t2.Museum_ID GROUP BY t2.Museum_ID ORDER BY count(*) DESC LIMIT 1
Database: museum_visit
Question sequence:
how many museums are there?
how many of them have not had any visitors yet?
what are their names?
SQL query sequence:
SELECT count(*) FROM museum
SELECT count(*) FROM museum WHERE Museum_ID NOT IN (SELECT museum_id FROM visit)
SELECT name FROM museum WHERE Museum_ID NOT IN (SELECT museum_id FROM visit)
Final question: What is the name of the museum that had no visitor yet?
Final SQL: SELECT name FROM museum WHERE Museum_ID NOT IN (SELECT museum_id FROM visit)
Database: museum_visit
Question sequence:
how many tickets were sold from all of the museums?
find the id of the visitor who bought the most tickets at once.
Find the name and age of this visitor.
SQL query sequence:
SELECT sum(num_of_ticket) FROM visit
SELECT visitor_id FROM visit ORDER BY num_of_ticket DESC LIMIT 1
SELECT t1.name,  t1.age FROM visitor AS t1 JOIN visit AS t2 ON t1.id  =  t2.visitor_id ORDER BY t2.num_of_ticket DESC LIMIT 1
Final question: Find the name and age of the visitor who bought the most tickets at once.
Final SQL: SELECT t1.name ,  t1.age FROM visitor AS t1 JOIN visit AS t2 ON t1.id  =  t2.visitor_id ORDER BY t2.num_of_ticket DESC LIMIT 1
Database: museum_visit
Question sequence:
find the total cost of all visits.
what was the amount of the largest one time purchase of tickets out of all visits?
how about the average and maximum number of tickets purchased?
SQL query sequence:
SELECT sum(Total_spent) FROM visit
SELECT max(Total_spent) FROM visit
SELECT avg(num_of_ticket) ,  max(num_of_ticket) FROM visit
Final question: What are the average and maximum number of tickets bought in all visits?
Final SQL: SELECT avg(num_of_ticket) ,  max(num_of_ticket) FROM visit
Database: museum_visit
Question sequence:
what is the lowest level of membership?
find the number of visitors whose membership level is 1.
show the ticket expenses of all of their museum visits.
what is the total amount of money spent?
SQL query sequence:
SELECT min(Level_of_membership) FROM visitor
SELECT count(*) FROM visitor WHERE Level_of_membership  =  1
SELECT t2.Total_spent FROM visitor AS t1 JOIN visit AS t2 ON t1.id  =  t2.visitor_id WHERE t1.Level_of_membership  =  1
SELECT sum(t2.Total_spent) FROM visitor AS t1 JOIN visit AS t2 ON t1.id  =  t2.visitor_id WHERE t1.Level_of_membership  =  1
Final question: What is the total ticket expense of the visitors whose membership level is 1?
Final SQL: SELECT sum(t2.Total_spent) FROM visitor AS t1 JOIN visit AS t2 ON t1.id  =  t2.visitor_id WHERE t1.Level_of_membership  =  1
Database: museum_visit
Question sequence:
find the names of museums opened before 2009.
what about those opened after 2011?
What is the name of the visitor who visited both groups of museums?
SQL query sequence:
SELECT name FROM museum WHERE open_year  <  2009
SELECT name FROM museum WHERE open_year > 2011
SELECT t1.name FROM visitor AS t1 JOIN visit AS t2 ON t1.id  =  t2.visitor_id JOIN museum AS t3 ON t3.Museum_ID  =  t2.Museum_ID WHERE t3.open_year  <  2009 INTERSECT SELECT t1.name FROM visitor AS t1 JOIN visit AS t2 ON t1.id  =  t2.visitor_id JOIN museum AS t3 ON t3.Museum_ID  =  t2.Museum_ID WHERE t3.open_year  >  2011
Final question: What is the name of the visitor who visited both a museum opened before 2009 and a museum opened after 2011?
Final SQL: SELECT t1.name FROM visitor AS t1 JOIN visit AS t2 ON t1.id  =  t2.visitor_id JOIN museum AS t3 ON t3.Museum_ID  =  t2.Museum_ID WHERE t3.open_year  <  2009 INTERSECT SELECT t1.name FROM visitor AS t1 JOIN visit AS t2 ON t1.id  =  t2.visitor_id JOIN museum AS t3 ON t3.Museum_ID  =  t2.Museum_ID WHERE t3.open_year  >  2011
Database: museum_visit
Question sequence:
find the names of museums opened after 2010
find the number of visits to these museums?
Find the number of visitors who did not visit these museums.
SQL query sequence:
SELECT name FROM museum WHERE open_year  >  2010
SELECT count(*) FROM museum AS t1 JOIN visit AS t2 ON t1.Museum_ID  =  t2.Museum_ID WHERE t1.open_year  >  2010
SELECT count(*) FROM visitor WHERE id NOT IN (SELECT t2.visitor_id FROM museum AS t1 JOIN visit AS t2 ON t1.Museum_ID  =  t2.Museum_ID WHERE t1.open_year  >  2010)
Final question: Find the number of visitors who did not visit any museum opened after 2010.
Final SQL: SELECT count(*) FROM visitor WHERE id NOT IN (SELECT t2.visitor_id FROM museum AS t1 JOIN visit AS t2 ON t1.Museum_ID  =  t2.Museum_ID WHERE t1.open_year  >  2010)
Database: network_1
Question sequence:
How many high schoolers are there?
How many in each grade 11 or 12?
How many in grade 9 or 10?
SQL query sequence:
SELECT count(*) FROM Highschooler
SELECT count(*) FROM Highschooler WHERE grade  =  11 OR grade  =  12
SELECT count(*) FROM Highschooler WHERE grade  =  9 OR grade  =  10
Final question: How many high schoolers are there in grade 9 or 10?
Final SQL: SELECT count(*) FROM Highschooler WHERE grade  =  9 OR grade  =  10
Database: network_1
Question sequence:
How many distinct grades are there?
What are they?
Which one has the least number of highschoolers?
Which one has the most?
SQL query sequence:
SELECT count(distinct grade) FROM Highschooler
SELECT distinct grade FROM Highschooler
SELECT grade FROM Highschooler GROUP BY grade ORDER BY count(*) ASC LIMIT 1
SELECT grade FROM Highschooler GROUP BY grade ORDER BY count(*) DESC LIMIT 1
Final question: Which grade has the most high schoolers?
Final SQL: SELECT grade FROM Highschooler GROUP BY grade ORDER BY count(*) DESC LIMIT 1
Database: network_1
Question sequence:
How many highschoolers are there in total?
How many per grade?
What grades have at least 10 students?
How about at least 4?
SQL query sequence:
SELECT count(*) FROM Highschooler
SELECT grade, count(*) FROM Highschooler GROUP BY grade
SELECT grade FROM Highschooler GROUP BY grade HAVING count(*)  >=  10
SELECT grade FROM Highschooler GROUP BY grade HAVING count(*)  >=  4
Final question: Show me all grades that have at least 4 students.
Final SQL: SELECT grade FROM Highschooler GROUP BY grade HAVING count(*)  >=  4
Database: network_1
Question sequence:
What are the names of all the high school students?
Show the names of the friends for each one.
How many friends does each student each have?
SQL query sequence:
SELECT name FROM highschooler
SELECT T2.name, T3.name FROM friend as T1 join highschooler as T2  on friend_id = T2.ID join highschooler as T3 on student_id = T3.ID
SELECT T2.name, count(*) FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id GROUP BY T1.student_id
Final question: Show the names of high school students and their corresponding number of friends.
Final SQL: SELECT T2.name, count(*) FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id GROUP BY T1.student_id
Database: network_1
Question sequence:
What are the names of all the high schoolers?
Show me the number of friends for each one.
Which one has the least number of friends?
How about the greatest?
SQL query sequence:
SELECT name FROM highschooler
SELECT T2.name, count(*) FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id GROUP BY T1.student_id
SELECT T2.name FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id GROUP BY T1.student_id ORDER BY count(*) ASC LIMIT 1
SELECT T2.name FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1
Final question: What is the name of the high schooler who has the greatest number of friends?
Final SQL: SELECT T2.name FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1
Database: network_1
Question sequence:
How many highschoolers have more than 5?
at least 3?
What are their names?
SQL query sequence:
SELECT count(*) FROM (SELECT * FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id GROUP BY T1.student_id HAVING count(*)  > 5)
SELECT count(*) FROM (SELECT * FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id GROUP BY T1.student_id HAVING count(*)  >= 3)
SELECT T2.name FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id GROUP BY T1.student_id HAVING count(*)  >=  3
Final question: Show the names of high schoolers who have at least 3 friends.
Final SQL: SELECT T2.name FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id GROUP BY T1.student_id HAVING count(*)  >=  3
Database: network_1
Question sequence:
Show me information on the high schooler named "Kyle."
How many friends does he have?
What are their names?
SQL query sequence:
SELECT * FROM highschooler where name = "Kyle"
SELECT count(*) FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id JOIN Highschooler AS T3 ON T1.friend_id  =  T3.id WHERE T2.name  =  "Kyle"
SELECT T3.name FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id JOIN Highschooler AS T3 ON T1.friend_id  =  T3.id WHERE T2.name  =  "Kyle"
Final question: Show the names of all of the high schooler Kyle's friends.
Final SQL: SELECT T3.name FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id JOIN Highschooler AS T3 ON T1.friend_id  =  T3.id WHERE T2.name  =  "Kyle"
Database: network_1
Question sequence:
Is there a highschooler named Kyle?
Who does he like?
What are the names of his friends?
How many are there?
SQL query sequence:
SELECT * FROM highschooler where name = "Kyle"
SELECT T3.name FROM Likes AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id JOIN Highschooler AS T3 ON T1.liked_id  =  T3.id WHERE T2.name  =  "Kyle"
SELECT T3.name FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id JOIN Highschooler AS T3 ON T1.friend_id  =  T3.id WHERE T2.name  =  "Kyle"
SELECT count(*) FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id JOIN Highschooler AS T3 ON T1.friend_id  =  T3.id WHERE T2.name  =  "Kyle"
Final question: How many friends does the high school student Kyle have?
Final SQL: SELECT count(*) FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id WHERE T2.name  =  "Kyle"
Database: network_1
Question sequence:
Show me all the high school student ids.
How many friends do each of them have?
Which ones have at least 1?
Which ones have none?
SQL query sequence:
SELECT ID FROM highschooler
SELECT student_id, count(*) FROM friend group by student_id
SELECT student_id FROM Friend
SELECT id FROM Highschooler EXCEPT SELECT student_id FROM Friend
Final question: Show ids of all students who do not have any friends.
Final SQL: SELECT id FROM Highschooler EXCEPT SELECT student_id FROM Friend
Database: network_1
Question sequence:
What are the names of all the highshcool students?
Which ones have at least 5 friends?
how about at least 1?
how about 0?
SQL query sequence:
SELECT name FROM highschooler
SELECT count(*) FROM (SELECT * FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id GROUP BY T1.student_id HAVING count(*)  >= 5)
SELECT distinct T2.name FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id
SELECT name FROM Highschooler EXCEPT SELECT T2.name FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id
Final question: Show names of all high school students who do not have any friends.
Final SQL: SELECT name FROM Highschooler EXCEPT SELECT T2.name FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id  =  T2.id
Database: network_1
Question sequence:
Show me the ids of all highschoolers who have friends?
Also show, for each, the ids of the people they like?
Now only show those who are liked by someone else!
Show me just their ids!
SQL query sequence:
SELECT student_id FROM Friend
SELECT distinct T1.student_id, T2.liked_id FROM Friend as T1 JOIN Likes as T2 ON T1.student_id = T2.student_id
SELECT distinct T1.student_id, T2.liked_id FROM Friend as T1 JOIN Likes as T2 ON T1.student_id = T2.student_id where T1.student_id in (SELECT liked_id FROM Likes)
SELECT student_id FROM Friend INTERSECT SELECT liked_id FROM Likes
Final question: Show the ids of high schoolers who have friends and are also liked by someone else.
Final SQL: SELECT student_id FROM Friend INTERSECT SELECT liked_id FROM Likes