To get the number of employees connected to a supervisor you can use the following code. Using Count to count the number of employees in select and group by supervisor name.
SELECT f.NomeFunc, count(s.ID_Superv)
FROM Funcionario f
INNER JOIN Funcionario s ON s.ID_Superv = f.ID_Func
GROUP BY f.NomeFunc
ORDER BY f.NomeFunc
having can be used when you want to filter the Count result value. Example, if you want to check all supervisors who have more than two employees connected to it you can use the following code:
SELECT f.NomeFunc, count(s.ID_Superv)
FROM Funcionario f
INNER JOIN Funcionario s ON s.ID_Superv = f.ID_Func
GROUP BY f.NomeFunc
HAVING(count(s.ID_Superv) > 2)
ORDER BY f.NomeFunc;
If this answer solved your problem and there is no doubt left, mark it as correct/accepted by clicking on the " " that is next to it, which also marks your question as solved. If you still have any questions or would like further clarification, feel free to comment.
– Augusto Vasques