Bird
0
0

Given the tables:

medium📝 query result Q13 of 15
PostgreSQL - Subqueries in PostgreSQL
Given the tables:
products(id, price)
and
discounts(min_price)
What does this query return?
SELECT id FROM products WHERE price > ALL (SELECT min_price FROM discounts);
AAll product ids regardless of price.
BProduct ids with price greater than every min_price in discounts.
CProduct ids with price equal to any min_price in discounts.
DProduct ids with price greater than at least one min_price in discounts.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the ALL condition

    The condition price > ALL (subquery) means price must be greater than every min_price returned.
  2. Step 2: Interpret the query result

    Only products with price higher than all discount min_prices are selected.
  3. Final Answer:

    Product ids with price greater than every min_price in discounts. -> Option B
  4. Quick Check:

    price > ALL means greater than all values [OK]
Quick Trick: ALL means condition holds for every subquery value [OK]
Common Mistakes:
  • Confusing ALL with ANY or SOME
  • Thinking it returns products with price greater than some min_price
  • Assuming it returns all products

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes