Database: activity_1

Question: Show all the faculty ranks and the number of students advised by each rank.
SQL: SELECT T1.rank ,  count(*) FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID  =  T2.advisor GROUP BY T1.rank

Question: What are the first and last name of the faculty who has the most students?
SQL: SELECT T1.fname ,  T1.lname FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID  =  T2.advisor GROUP BY T1.FacID ORDER BY count(*) DESC LIMIT 1

Question: Show the ids for all the faculty members who have at least 2 students.
SQL: SELECT T1.FacID FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID  =  T2.advisor GROUP BY T1.FacID HAVING count(*)  >=  2

Question: Show ids for the faculty members who don't advise any student.
SQL: SELECT FacID FROM Faculty EXCEPT SELECT advisor FROM Student

Question: What activities do we have?
SQL: SELECT activity_name FROM Activity

Question: How many activities do we have?
SQL: SELECT count(*) FROM Activity

Question: How many faculty members participate in an activity?
SQL: SELECT count(DISTINCT FacID) FROM Faculty_participates_in

Question: Show the ids of the faculty who don't participate in any activity.
SQL: SELECT FacID FROM Faculty EXCEPT SELECT FacID FROM Faculty_participates_in

Question: Show the ids of all the faculty members who participate in an activity and advise a student.
SQL: SELECT FacID FROM Faculty_participates_in INTERSECT SELECT advisor FROM Student

Question: How many activities does Mark Giuliano participate in?
SQL: SELECT count(*) FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID  =  T2.facID WHERE T1.fname  =  "Mark" AND T1.lname  =  "Giuliano"

Question: Show the names of all the activities Mark Giuliano participates in.
SQL: SELECT T3.activity_name FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID  =  T2.facID JOIN Activity AS T3 ON T3.actid  =  T2.actid WHERE T1.fname  =  "Mark" AND T1.lname  =  "Giuliano"

Question: Show the first and last name of all the faculty members who participated in some activity, together with the number of activities they participated in.
SQL: SELECT  T1.fname ,  T1.lname ,  count(*) FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID  =  T2.facID GROUP BY T1.FacID

Question: Show all the activity names and the number of faculty involved in each activity.
SQL: SELECT T1.activity_name ,  count(*) FROM Activity AS T1 JOIN Faculty_participates_in AS T2 ON T1.actID  =  T2.actID GROUP BY T1.actID

Question: What is the first and last name of the faculty participating in the most activities?
SQL: SELECT  T1.fname ,  T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID  =  T2.facID GROUP BY T1.FacID ORDER BY count(*) DESC LIMIT 1

Question: What is the name of the activity that has the most faculty members involved in?
SQL: SELECT T1.activity_name FROM Activity AS T1 JOIN Faculty_participates_in AS T2 ON T1.actID  =  T2.actID GROUP BY T1.actID ORDER BY count(*) DESC LIMIT 1

Question: Show the ids of the students who don't participate in any activity.
SQL: SELECT StuID FROM Student EXCEPT SELECT StuID FROM Participates_in