I am using oracle's SQL Developer. To begin with, I have this table:
Name Null Type
-------------- -------- ------------
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
DEPARTMENT_ID NUMBER(4)
I would like for each employee to show his name and the number of colleagues from his department. This is what I got so far:
select first_name, department_id, count(employee_id)
from employees
group by department_id;
This generates an error:
ORA-00979: not a GROUP BY expression
00979. 00000 - "not a GROUP BY expression"
I would really need some help. I am a total beginner so any suggestion is welcome.
UPDATE: So, for each Employee, I want to show the number of his colleagues from the same department, and his name. I have updated the question.