Bird
0
0

Identify the error in this query:

medium📝 Debug Q6 of 15
PostgreSQL - Subqueries in PostgreSQL
Identify the error in this query:
SELECT name FROM employees WHERE salary > SELECT AVG(salary) FROM employees;
AAVG function cannot be used in WHERE clause
BIncorrect table name
Csalary column does not exist
DMissing parentheses around the subquery
Step-by-Step Solution
Solution:
  1. Step 1: Check subquery syntax

    Subqueries must be enclosed in parentheses to be valid.
  2. Step 2: Identify missing parentheses

    The query lacks parentheses around the subquery, causing syntax error.
  3. Final Answer:

    Missing parentheses around the subquery -> Option D
  4. Quick Check:

    Subqueries require parentheses () [OK]
Quick Trick: Always wrap subqueries in parentheses to avoid syntax errors [OK]
Common Mistakes:
  • Omitting parentheses around subqueries
  • Assuming AVG can't be used in WHERE
  • Mistaking column or table names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes