Complete the code to select products with a price greater than all prices in the 'discounts' table.
SELECT product_name FROM products WHERE price > [1] (SELECT discount_price FROM discounts);The keyword ALL compares the value to all values returned by the subquery. Here, it selects products priced higher than every discount price.
Complete the code to find employees whose salary is less than or equal to some salaries in the 'managers' table.
SELECT employee_name FROM employees WHERE salary <= [1] (SELECT salary FROM managers);The keyword ANY means the condition is true if it matches at least one value from the subquery. Here, it finds employees earning less than or equal to at least one manager's salary.
Fix the error in the query to select orders with quantity greater than some quantities in 'order_details'.
SELECT order_id FROM orders WHERE quantity > [1] (SELECT quantity FROM order_details);The keyword ANY is correct here because we want orders with quantity greater than at least one quantity in 'order_details'. Using ALL would require quantity to be greater than every quantity, which is different.
Fill both blanks to select customers whose total orders are less than all totals in 'vip_orders'.
SELECT customer_id FROM customers WHERE total_orders [1] [2] (SELECT total FROM vip_orders);
The operator < combined with ALL means the customer's total orders are less than every total in 'vip_orders'.
Fill all three blanks to select products priced greater than some prices but less than all prices in 'competitor_prices'.
SELECT product_name FROM products WHERE price [1] [2] (SELECT price FROM competitor_prices) AND price [3] (SELECT price FROM competitor_prices);
The query finds products with price greater than ANY competitor price (some prices) and less than ALL competitor prices (every price). So, price > ANY and price < ALL.