Bird
0
0

Which of the following is the correct syntax to start a CTE in PostgreSQL?

easy📝 Syntax Q12 of 15
PostgreSQL - Common Table Expressions
Which of the following is the correct syntax to start a CTE in PostgreSQL?
AWITH cte_name AS (SELECT * FROM table_name)
BCREATE CTE cte_name SELECT * FROM table_name
CDEFINE cte_name AS SELECT * FROM table_name
DSTART CTE cte_name (SELECT * FROM table_name)
Step-by-Step Solution
Solution:
  1. Step 1: Recall CTE syntax

    In PostgreSQL, a CTE starts with the keyword WITH followed by the CTE name and AS, then the query in parentheses.
  2. Step 2: Check each option

    Only WITH cte_name AS (SELECT * FROM table_name) matches the correct syntax. Options A, C, and D use invalid keywords or structure.
  3. Final Answer:

    WITH cte_name AS (SELECT * FROM table_name) -> Option A
  4. Quick Check:

    CTE starts with WITH ... AS (...) = B [OK]
Quick Trick: CTEs always start with WITH keyword [OK]
Common Mistakes:
  • Using CREATE instead of WITH
  • Omitting AS keyword
  • Not enclosing query in parentheses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes