Bird
0
0

You need to create an inline table with columns user_id (integer), username (text), and is_active (boolean). Which query correctly uses the VALUES clause to achieve this?

hard📝 Application Q8 of 15
PostgreSQL - Set Operations and Advanced Queries
You need to create an inline table with columns user_id (integer), username (text), and is_active (boolean). Which query correctly uses the VALUES clause to achieve this?
AVALUES (101, 'alice', TRUE), (102, 'bob', FALSE) AS users(user_id, username, is_active);
BSELECT * FROM (VALUES (101, 'alice', TRUE), (102, 'bob', FALSE)) AS users(user_id, username, is_active);
CSELECT * FROM VALUES (101, 'alice', TRUE), (102, 'bob', FALSE) AS users(user_id, username, is_active);
DSELECT * FROM (VALUES (101, 'alice'), (102, 'bob')) AS users(user_id, username, is_active);
Step-by-Step Solution
Solution:
  1. Step 1: Confirm correct VALUES syntax

    VALUES must be enclosed in parentheses and used inside FROM with proper aliasing.
  2. Step 2: Check column count and data types

    SELECT * FROM (VALUES (101, 'alice', TRUE), (102, 'bob', FALSE)) AS users(user_id, username, is_active); correctly provides three columns matching alias names and data types.
  3. Final Answer:

    SELECT * FROM (VALUES (101, 'alice', TRUE), (102, 'bob', FALSE)) AS users(user_id, username, is_active); -> Option B
  4. Quick Check:

    VALUES with matching columns and alias inside FROM [OK]
Quick Trick: Match VALUES columns with alias inside FROM clause [OK]
Common Mistakes:
  • Omitting FROM clause
  • Mismatching column count
  • Incorrect boolean literals

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes