Question: Question - 1 You have been assigned to create a database procedure that calculates the average salary of employees in a specific department. Write a

Question-1
You have been assigned to create a database procedure that calculates the average salary of
employees in a specific department. Write a stored procedure in SQL that takes the department ID as
input and returns the average salary of employees in that department. Assume you have the
following tables:
Table: Employees
Table: Departments
Please write a stored procedure named GetAverageSalaryByDepartment that accepts a department
ID as a parameter and returns the average salary of employees in that department. If the department
ID is invalid, the procedure should return an error message saying "the department does not exist".
Note: You can assume that the department IDs are unique and refer to valid departments in the
Departments table.
Please provide the SQL code for the GetAverageSalaryByDepartment stored procedure.
 Question-1 You have been assigned to create a database procedure that

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!