Bird
0
0

Which of the following queries correctly uses the VALUES clause to create two rows each with a single column named color?

easy📝 Conceptual Q2 of 15
PostgreSQL - Set Operations and Advanced Queries
Which of the following queries correctly uses the VALUES clause to create two rows each with a single column named color?
ASELECT * FROM VALUES ('Green'), ('Yellow') AS t(color);
BVALUES ('Green'), ('Yellow') AS t(color);
CSELECT * FROM (VALUES ('Green'), ('Yellow')) AS t(color);
DVALUES ('Green', 'Yellow') AS t(color);
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax for VALUES with alias

    The correct syntax wraps VALUES in a FROM clause and aliases the columns.
  2. Step 2: Validate options

    SELECT * FROM (VALUES ('Green'), ('Yellow')) AS t(color); correctly uses SELECT * FROM (VALUES ...) AS t(color).
  3. Final Answer:

    SELECT * FROM (VALUES ('Green'), ('Yellow')) AS t(color); -> Option C
  4. Quick Check:

    VALUES must be inside FROM with alias [OK]
Quick Trick: Wrap VALUES in FROM and alias columns [OK]
Common Mistakes:
  • Using VALUES without FROM
  • Incorrect alias placement
  • Passing multiple values in one row for single column

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes