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
What ranks do we have for faculty?
assistant
SELECT DISTINCT rank FROM Faculty
human
Show the rank, first name, and last name for all the faculty.
assistant
SELECT rank , Fname , Lname FROM Faculty
human
Show the faculty id of each faculty member, along with the number of students he or she advises.
assistant
SELECT T1.FacID , count(*) FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID = T2.advisor GROUP BY T1.FacID
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
For each faculty rank, show the number of faculty members who have it.
assistant
SELECT rank , count(*) FROM Faculty GROUP BY rank
human
How many students are advised by each rank of faculty? List the rank and the number of students.
assistant
SELECT T1.rank , COUNT( * ) FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID = T2.advisor GROUP BY T1.rank ;