I need to create a procedure to find the department name of the department with the most employees.
I am not allowed to use temp. tables as those were not seen in my course.
Code below
CREATE OR REPLACE PROCEDURE grootste_dept
IS v_department departments.department_name%type;
BEGIN
SELECT department_name
INTO v_department
FROM departments d
JOIN employees e
ON d.department_id = e.department_id
GROUP BY department_name
HAVING COUNT(employee_id) = MAX(COUNT(employee_id);
DBMS_OUTPUT.PUT_LINE(v_department);
END;
/
Expected value = dept_name from dept with most emps
4/1 PL/SQL: SQL Statement ignored
10/33 PL/SQL: ORA-00935: group function is nested too deeply