Help me in solving PLSQL41 problem

My issue

anyone have, knowledge regarding how to solve this problem…already tried many approach but same testcase failed error, don’t know what to do

My code

CREATE TABLE employees (
    emp_id INT PRIMARY KEY,
    emp_name VARCHAR2(50),
    department VARCHAR2(50),
    salary INT
);


INSERT INTO employees (emp_id, emp_name, department, salary) VALUES (101, 'John', 'HR', 50000);
INSERT INTO employees (emp_id, emp_name, department, salary) VALUES (102, 'Alice', 'HR', 60000);
INSERT INTO employees (emp_id, emp_name, department, salary) VALUES (103, 'Bob', 'HR', 55000);
INSERT INTO employees (emp_id, emp_name, department, salary) VALUES (104, 'Charlie', 'Operations', 52000);
INSERT INTO employees (emp_id, emp_name, department, salary) VALUES (105, 'David', 'Operations', 53000);

CREATE TABLE department_salary (
    department VARCHAR2(50) PRIMARY KEY,
    avg_salary INT
);


-- Step 1: Create or Replace the Trigger
CREATE OR REPLACE TRIGGER update_department_salary
AFTER INSERT OR UPDATE ON employees
FOR EACH ROW
BEGIN
    -- Delete existing records for the affected department
    DELETE FROM department_salary
    WHERE department = :NEW.department;

    -- Insert updated average salary for the affected department
    INSERT INTO department_salary (department, avg_salary)
    SELECT department, TRUNC(AVG(salary))
    FROM employees
    WHERE department = :NEW.department
    GROUP BY department;
END;
/





Learning course: Database management systems
Problem Link: Practice - Multiple table udpate in Database management systems