Complete the code to select all employees who work in the department with ID 5.
SELECT * FROM employees WHERE department_id = [1];The query filters employees whose department_id equals 5.
Complete the code to select employees who work in the department named 'Sales' using a subquery.
SELECT * FROM employees WHERE department_id = (SELECT [1] FROM departments WHERE name = 'Sales');
The subquery must return the id of the department named 'Sales' to match department_id in employees.
Fix the error in the subquery to find employees with salary greater than the average salary.
SELECT * FROM employees WHERE salary > (SELECT [1] FROM employees);The subquery must calculate the average salary using AVG(salary) to compare each employee's salary.
Fill both blanks to select employees who work in departments with more than 10 employees.
SELECT * FROM employees WHERE department_id IN (SELECT [1] FROM departments WHERE [2] > 10);
department_id in the WHERE clause instead of employee count.The subquery selects department id where the number of employees (num_employees) is greater than 10.
Fill all three blanks to select employees whose salary is above the average salary in their department.
SELECT * FROM employees e WHERE salary > (SELECT AVG([1]) FROM employees WHERE [2] = e.[3]);
The subquery calculates the average salary for employees in the same department_id as the outer query employee.