Complete the code to update the salary of employees to 50000 where their department is 'Sales'.
UPDATE employees SET salary = [1] WHERE department = 'Sales';
The salary should be set to the number 50000 without quotes because salary is a numeric column.
Complete the code to update the salary of employees to the average salary of their department.
UPDATE employees SET salary = (SELECT AVG(salary) FROM employees WHERE department = [1]);The subquery compares the department column of the outer query with the department column inside the subquery, so no quotes are needed.
Fix the error in the code to update employees' salary to the maximum salary in their department.
UPDATE employees SET salary = (SELECT MAX(salary) FROM employees WHERE department = [1]);The subquery must compare the department column of the outer query to the inner query's department column without quotes.
Fill both blanks to update employees' bonus to 10% of their salary where their department is 'Sales'.
UPDATE employees SET bonus = salary * [1] WHERE department = [2];
The bonus is 10% so 0.1 is used. The department is a string, so it needs quotes.
Fill all three blanks to update employees' salary to the average salary of their department only if their current salary is below that average.
UPDATE employees SET salary = (SELECT AVG(salary) FROM employees WHERE department = [1]) WHERE salary < (SELECT AVG(salary) FROM employees WHERE department = [2]) AND department = [3];
The subqueries compare the department column, so use the column name without quotes. The final department filter is a string, so it needs quotes.