Bird
0
0

Which of the following is the correct syntax for a subquery in PostgreSQL?

easy📝 Syntax Q12 of 15
PostgreSQL - Subqueries in PostgreSQL
Which of the following is the correct syntax for a subquery in PostgreSQL?
ASELECT * FROM table WHERE column == (SELECT MAX(column) FROM table);
BSELECT * FROM table WHERE column = (SELECT MAX(column) FROM table);
CSELECT * FROM table WHERE column = SELECT MAX(column) FROM table;
DSELECT * FROM table WHERE column IN SELECT MAX(column) FROM table;
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct subquery syntax

    Subqueries must be enclosed in parentheses and used with comparison operators like = or IN.
  2. Step 2: Check each option

    SELECT * FROM table WHERE column = (SELECT MAX(column) FROM table); correctly uses parentheses and = with a subquery. The other options have syntax errors like using == instead of =, omitting parentheses entirely, or missing them after IN.
  3. Final Answer:

    SELECT * FROM table WHERE column = (SELECT MAX(column) FROM table); -> Option B
  4. Quick Check:

    Subqueries need parentheses and proper operators [OK]
Quick Trick: Subqueries always go inside parentheses [OK]
Common Mistakes:
  • Using double equals (==) instead of single equals (=)
  • Omitting parentheses around subqueries
  • Using IN without parentheses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes