I need help writing a Sql command. I am pretty new at sql so everything is a little confusing. The problem: For each instructor list his / her name and the number of students he / she mentors
There are three tables:
- Person with the Names and ID
- Instructor with Instructor ID which references ID
- Student with StudentID and MentorID which references ID
I tried:
select distinct p.Name,count(d.MentorID)
from Person p, Instructor e, Student d
where e.InstructorID = d.MentorID
and p.ID = e.InstructorID;
But that only gives me one results instead a count per instructor.
GROUPandHAVING