human
Schema:
Activity (actid, activity_name)
Participates_in (stuid, actid)
Faculty_Participates_in (FacID, actid)
Student (StuID, LName, Fname, Age, Sex, Major, Advisor, city_code)
Faculty (FacID, Lname, Fname, Rank, Sex, Phone, Room, Building)
Please answer with SQL.
assistant
Sure, I understand.
human
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.
assistant
SELECT T1.fname , T1.lname , count(*) , T1.FacID FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID GROUP BY T1.FacID
human
Show the first name, last name, and phone number for all female faculty members.
assistant
SELECT Fname , Lname , phone FROM Faculty WHERE Sex = 'F'
human
For each faculty rank, show the number of faculty members who have it.
assistant
SELECT rank , count(*) FROM Faculty GROUP BY rank
human
Show all the faculty ranks and the number of students advised by each rank.
assistant
SELECT T1.rank , count(*) FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID = T2.advisor GROUP BY T1.rank
human
Show all the ranks and the number of male and female faculty for each rank.
assistant
SELECT rank , sex , count(*) FROM Faculty GROUP BY rank , sex
human
Show the rank, first name, and last name for all the faculty.
assistant
SELECT rank , Fname , Lname FROM Faculty ;