SQL in Oracle HR Schema
02:17 17 Oct 2020

I have made a query in Oracle HR schema to see the following information:

  1. The city where the department is located
  2. The total number of employees in the department

However, the query cannot be executed correctly and said this is "not a GROUP BY expression".

Does anyone knows what's the problem is? Thanks in advance.

SELECT department_name, city, COUNT(employees.department_id)
   FROM departments
       JOIN employees on (departments.department_id=employees.department_id)
         JOIN locations USING (location_id)
GROUP BY department_name;
sql oracle-database oracle18c