Resolved: why this code is not valid
create view average_salaryy as
select avg(s.salary) as total_Salary
from dept_manager d
join salaries s on d.emp_no = s.emp_no
where salary = (select sum(s.salary) from salaries);
Thanks for reaching out.
You do not need to assign the sum of the salaries. You need to simply join the tables and use the
AVG() aggregate function.
Please, use the following code:
CREATE VIEW average_salaryy AS
AVG(s.salary) AS total_Salary
salaries s ON d.emp_no = s.emp_no;
Hope this helps.