update employees set salary = 300 + (select avg(salary) from employees where departmentid = 30) where departmentid = 50