Using PL/SQL for More Complex Operations

You can create a PL/SQL block to calculate and display the average salary of employees in a specific department:

DECLARE
    avg_salary NUMBER;
BEGIN
    SELECT AVG(salary) INTO avg_salary FROM employees WHERE department_id = 1;
    DBMS_OUTPUT.PUT_LINE('Average Salary for Department 1: ' || avg_salary);
END;
/


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *