Bird
0
0

Consider the table orders(amount) with values 100, 200, 300. What does this query return?

medium📝 query result Q5 of 15
PostgreSQL - Subqueries in PostgreSQL
Consider the table orders(amount) with values 100, 200, 300. What does this query return?
SELECT amount FROM orders WHERE amount < ANY (SELECT amount FROM orders WHERE amount > 150);
ANo rows
B200, 300
C100
D100, 200
Step-by-Step Solution
Solution:
  1. Step 1: Identify subquery results

    The subquery returns amounts greater than 150: 200 and 300.
  2. Step 2: Evaluate condition amount < ANY (200, 300)

    Amount must be less than at least one value in (200, 300).
  3. Step 3: Find amounts satisfying condition

    100 < 200 (true), < 300 (true). 200 < 200 (false) but 200 < 300 (true), so yes. 300 < 200 (false), < 300 (false), no. Returns 100, 200.
  4. Final Answer:

    100, 200 -> Option D
  5. Quick Check:

    ANY means condition true for at least one value = A [OK]
Quick Trick: ANY means condition true for at least one subquery value [OK]
Common Mistakes:
  • Excluding 200 thinking it equals the minimum subquery value
  • Confusing ANY with ALL
  • Thinking only 100 qualifies

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes