Complete the code to select employees who earn more than the average salary.
SELECT name FROM employees WHERE salary > (SELECT [1] FROM employees);The subquery calculates the average salary. The main query selects employees earning more than this average.
Complete the code to find products with prices higher than the average price.
SELECT product_name FROM products WHERE price > (SELECT [1] FROM products);The subquery calculates the average price. The main query selects products priced above this average.
Fix the error in the query to select customers who placed orders with amounts greater than the average order amount.
SELECT customer_id FROM orders WHERE order_amount > (SELECT [1](order_amount) FROM orders);The subquery needs the AVG function to calculate the average order amount. Without AVG, the query is invalid.
Fill both blanks to select employees whose salary is greater than the average salary in their department.
SELECT name FROM employees WHERE salary > (SELECT [1] FROM employees WHERE department_id = [2]);
The subquery calculates the average salary for the employee's department. The main query compares each employee's salary to this average.
Fill all three blanks to select products with price greater than the average price in their category and category matches the main query.
SELECT product_name FROM products WHERE price > (SELECT [1] FROM products WHERE category_id = [2]) AND category_id = [3];
The subquery calculates the average price for the category. The main query selects products priced above this average and in the same category.