Complete the code to select all employees who work in departments listed in the subquery.
SELECT * FROM employees WHERE department_id [1] (SELECT id FROM departments WHERE location = 'New York');
The IN operator is used to check if a value matches any value in a list or subquery result.
Complete the code to find all products whose category_id is in the list of categories with 'active' status.
SELECT product_name FROM products WHERE category_id [1] (SELECT id FROM categories WHERE status = 'active');
The IN operator checks if category_id is among the IDs returned by the subquery.
Fix the error in the query to select customers who have placed orders in 2023.
SELECT * FROM customers WHERE customer_id [1] (SELECT customer_id FROM orders WHERE order_date >= '2023-01-01');
The IN operator is needed because the subquery returns multiple customer IDs.
Fill both blanks to select all employees whose department is in the list of departments located in 'Chicago' and whose salary is greater than 50000.
SELECT name FROM employees WHERE department_id [1] (SELECT id FROM departments WHERE city = 'Chicago') AND salary [2] 50000;
The first blank needs IN to check department membership. The second blank needs > to filter salaries greater than 50000.
Fill all three blanks to select product names and prices for products in categories that are active and have a discount greater than 10.
SELECT product_name, price FROM products WHERE category_id [1] (SELECT id FROM categories WHERE status = [2]) AND discount [3] 10;
The first blank uses IN to check category membership. The second blank uses 'active' as a string literal for status. The third blank uses > to filter discounts greater than 10.