Bird
0
0

What is the syntax error in the following SQL query?

medium📝 Debug Q6 of 15
SQL - Window Functions Fundamentals
What is the syntax error in the following SQL query?

SELECT Department, Employee, AVG(Salary) OVER PARTITION BY Department FROM Employees;
AIncorrect use of AVG function without GROUP BY.
BMissing parentheses around the OVER clause.
CPARTITION BY cannot be used with aggregate functions.
DOVER clause must follow the GROUP BY clause.
Step-by-Step Solution
Solution:
  1. Step 1: Check OVER clause syntax

    The OVER clause must be enclosed in parentheses when used with PARTITION BY.
  2. Step 2: Identify the error

    The query misses parentheses around PARTITION BY Department, causing a syntax error.
  3. Final Answer:

    Missing parentheses around the OVER clause. -> Option B
  4. Quick Check:

    Always use parentheses after OVER with PARTITION BY. [OK]
Quick Trick: Use parentheses after OVER with PARTITION BY [OK]
Common Mistakes:
  • Omitting parentheses after OVER
  • Confusing window functions with GROUP BY aggregates
  • Placing PARTITION BY outside OVER clause

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes