Database: network_1
# highschooler ( id , name , grade )
# friend ( student_id , friend_id )
# likes ( student_id , liked_id )
# friend.friend_id = highschooler.id
# friend.student_id = highschooler.id
# likes.student_id = highschooler.id
# likes.liked_id = highschooler.id

Question: How many high schoolers are there?
SQL: select count ( * ) from highschooler

Question: Count the number of high schoolers.
SQL: select count ( * ) from highschooler

Question: Show the names and grades of each high schooler.
SQL: select name , grade from highschooler

Question: What are the names and grades for each high schooler?
SQL: select name , grade from highschooler

Question: Show all the grades of the high schoolers.
SQL: select grade from highschooler

Question: What is the grade of each high schooler?
SQL: select grade from highschooler

Question: What grade is Kyle in?
SQL: select grade from highschooler where name = 'Kyle'

Question: Return the grade for the high schooler named Kyle.
SQL: select grade from highschooler where name = 'Kyle'

Question: Show the names of all high schoolers in grade 10.
SQL: select name from highschooler where grade = 10

Question: What are the names of all high schoolers in grade 10?
SQL: select name from highschooler where grade = 10

Question: Show the ID of the high schooler named Kyle.
SQL: select id from highschooler where name = 'Kyle'

Question: What is Kyle's id?
SQL: select id from highschooler where name = 'Kyle'

Question: How many high schoolers are there in grade 9 or 10?
SQL: select count ( * ) from highschooler where grade = 9 or grade = 10

Question: Count the number of high schoolers in grades 9 or 10.
SQL: select count ( * ) from highschooler where grade = 9 or grade = 10

Question: Show the number of high schoolers for each grade.
SQL: select grade , count ( * ) from highschooler group by grade

Question: How many high schoolers are in each grade?
SQL: select grade , count ( * ) from highschooler group by grade

Question: Which grade has the most high schoolers?
SQL: select grade from highschooler group by grade order by count ( * ) desc limit 1

Question: Return the grade that has the greatest number of high schoolers.
SQL: select grade from highschooler group by grade order by count ( * ) desc limit 1

Question: Show me all grades that have at least 4 students.
SQL: select grade from highschooler group by grade having count ( * ) >= 4

Question: Which grades have 4 or more high schoolers?
SQL: select grade from highschooler group by grade having count ( * ) >= 4

Question: Show the student IDs and numbers of friends corresponding to each.
SQL: select student_id , count ( * ) from friend group by student_id

Question: How many friends does each student have?
SQL: select student_id , count ( * ) from friend group by student_id

Question: Show the names of high school students and their corresponding number of friends.
SQL: select highschooler.name , count ( * ) from friend join highschooler on friend.student_id = highschooler.id group by friend.student_id

Question: What are the names of the high schoolers and how many friends does each have?
SQL: select highschooler.name , count ( * ) from friend join highschooler on friend.student_id = highschooler.id group by friend.student_id

Question: What is the name of the high schooler who has the greatest number of friends?
SQL: select highschooler.name from friend join highschooler on friend.student_id = highschooler.id group by friend.student_id order by count ( * ) desc limit 1

Question: Return the name of the high school student with the most friends.
SQL: select highschooler.name from friend join highschooler on friend.student_id = highschooler.id group by friend.student_id order by count ( * ) desc limit 1

Question: Show the names of high schoolers who have at least 3 friends.
SQL: select highschooler.name from friend join highschooler on friend.student_id = highschooler.id group by friend.student_id having count ( * ) >= 3

Question: What are the names of high schoolers who have 3 or more friends?
SQL: select highschooler.name from friend join highschooler on friend.student_id = highschooler.id group by friend.student_id having count ( * ) >= 3

Question: Show the names of all of the high schooler Kyle's friends.
SQL: select highschooler.name from friend join highschooler on friend.student_id = highschooler.id join highschooler on friend.friend_id = highschooler.id where highschooler.name = 'Kyle'

Question: Return the names of friends of the high school student Kyle.
SQL: select highschooler.name from friend join highschooler on friend.student_id = highschooler.id join highschooler on friend.friend_id = highschooler.id where highschooler.name = 'Kyle'

Question: How many friends does the high school student Kyle have?
SQL: select count ( * ) from friend join highschooler on friend.student_id = highschooler.id where highschooler.name = 'Kyle'

Question: Count the number of friends Kyle has.
SQL: select count ( * ) from friend join highschooler on friend.student_id = highschooler.id where highschooler.name = 'Kyle'

Question: Show ids of all students who do not have any friends.
SQL: select id from highschooler except select student_id from friend

Question: What are the ids of high school students who do not have friends?
SQL: select id from highschooler except select student_id from friend

Question: Show names of all high school students who do not have any friends.
SQL: select name from highschooler except select highschooler.name from friend join highschooler on friend.student_id = highschooler.id

Question: What are the names of students who have no friends?
SQL: select name from highschooler except select highschooler.name from friend join highschooler on friend.student_id = highschooler.id

Question: Show the ids of high schoolers who have friends and are also liked by someone else.
SQL: select student_id from friend intersect select liked_id from likes

Question: What are the ids of students who both have friends and are liked?
SQL: select student_id from friend intersect select liked_id from likes

Question: Show name of all students who have some friends and also are liked by someone else.
SQL: select highschooler.name from friend join highschooler on likes.student_id = highschooler.id intersect select highschooler.name from likes join highschooler on likes.liked_id = highschooler.id

Question: What are the names of high schoolers who both have friends and are liked?
SQL: select highschooler.name from friend join highschooler on likes.student_id = highschooler.id intersect select highschooler.name from likes join highschooler on likes.liked_id = highschooler.id

Question: Count the number of likes for each student id.
SQL: select student_id , count ( * ) from likes group by student_id

Question: How many likes correspond to each student id?
SQL: select student_id , count ( * ) from likes group by student_id

Question: Show the names of high schoolers who have likes, and numbers of likes for each.
SQL: select highschooler.name , count ( * ) from likes join highschooler on likes.student_id = highschooler.id group by likes.student_id

Question: What are the names of high schoolers who have likes, and how many likes does each have?
SQL: select highschooler.name , count ( * ) from likes join highschooler on likes.student_id = highschooler.id group by likes.student_id

Question: What is the name of the high schooler who has the greatest number of likes?
SQL: select highschooler.name from likes join highschooler on likes.student_id = highschooler.id group by likes.student_id order by count ( * ) desc limit 1

Question: Give the name of the student with the most likes.
SQL: select highschooler.name from likes join highschooler on likes.student_id = highschooler.id group by likes.student_id order by count ( * ) desc limit 1

Question: Show the names of students who have at least 2 likes.
SQL: select highschooler.name from likes join highschooler on likes.student_id = highschooler.id group by likes.student_id having count ( * ) >= 2

Question: What are the names of students who have 2 or more likes?
SQL: select highschooler.name from likes join highschooler on likes.student_id = highschooler.id group by likes.student_id having count ( * ) >= 2

Question: Show the names of students who have a grade higher than 5 and have at least 2 friends.
SQL: select highschooler.name from friend join highschooler on friend.student_id = highschooler.id where highschooler.grade > 5 group by friend.student_id having count ( * ) >= 2

Question: What are the names of high schoolers who have a grade of over 5 and have 2 or more friends?
SQL: select highschooler.name from friend join highschooler on friend.student_id = highschooler.id where highschooler.grade > 5 group by friend.student_id having count ( * ) >= 2

Question: How many likes does Kyle have?
SQL: select count ( * ) from likes join highschooler on likes.student_id = highschooler.id where highschooler.name = 'Kyle'

Question: Return the number of likes that the high schooler named Kyle has.
SQL: select count ( * ) from likes join highschooler on likes.student_id = highschooler.id where highschooler.name = 'Kyle'

Question: Find the average grade of all students who have some friends.
SQL: select avg ( grade ) from highschooler where id in ( select friend.student_id from friend join highschooler on friend.student_id = highschooler.id )

Question: What is the average grade of students who have friends?
SQL: select avg ( grade ) from highschooler where id in ( select friend.student_id from friend join highschooler on friend.student_id = highschooler.id )

Question: Find the minimum grade of students who have no friends.
SQL: select min ( grade ) from highschooler where id not in ( select friend.student_id from friend join highschooler on friend.student_id = highschooler.id )

Question: What is the lowest grade of students who do not have any friends?
SQL: select min ( grade ) from highschooler where id not in ( select friend.student_id from friend join highschooler on friend.student_id = highschooler.id )