Bird
0
0

What will be the output of this query?

medium📝 query result Q4 of 15
PostgreSQL - Set Operations and Advanced Queries
What will be the output of this query?
SELECT * FROM (VALUES (10, 'X'), (20, 'Y')) AS t(num, letter) WHERE num > 15;
A10 | X
B20 | Y
C10 | X and 20 | Y
DNo rows returned
Step-by-Step Solution
Solution:
  1. Step 1: Understand the VALUES data and aliasing

    The VALUES clause creates two rows: (10, 'X') and (20, 'Y') with columns num and letter.
  2. Step 2: Apply the WHERE filter num > 15

    Only the row with num = 20 satisfies the condition, so only that row is returned.
  3. Final Answer:

    20 | Y -> Option B
  4. Quick Check:

    Filter num > 15 returns only 20 | Y [OK]
Quick Trick: WHERE filters rows after VALUES inline data [OK]
Common Mistakes:
  • Returning all rows ignoring WHERE
  • Returning no rows by mistake

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes