Reputation: 3
I'm trying to count the Total Number of Supervisors for each branch according to branch ID (B001, B002, B003). I'm trying to get the result like 'Sandy' counted as 1 and 'Mandy' counted as another (total 2 supervisors for B001) but after i executed, the result showed 3 (Sandy counted separately as 2 different values instead of 1). so, what should i do to make total number of supervisor in B001 branch becomes 2.
results shown: 2
SELECT Staff.BranchID,Branch.Manager AS ManagerName,
COUNT (staff.Supervisor) AS TotalNumberofSupervisor
FROM Staff INNER JOIN Branch ON Branch.BranchID = Staff.BranchID
GROUP BY Staff.BranchID,Branch.Manager
Upvotes: 0
Views: 29
Reputation: 180
I think "COUNT (distinct(staff.Supervisor))" instead of "COUNT (staff.Supervisor)" will help
Upvotes: 1