Bird
0
0

Identify the error in this query:

medium📝 Debug Q14 of 15
PostgreSQL - Window Functions in PostgreSQL
Identify the error in this query:
SELECT employee_id, salary, COUNT(*) OVER PARTITION BY department FROM employees;
ACOUNT(*) cannot be used as a window function.
BMissing parentheses around PARTITION BY clause in OVER().
Cemployee_id cannot be selected with window functions.
DNo error; query is correct.
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax of window function

    OVER clause must have parentheses: OVER (PARTITION BY department).
  2. Step 2: Validate other parts

    COUNT(*) is valid as window function; selecting employee_id is allowed.
  3. Final Answer:

    Missing parentheses around PARTITION BY clause in OVER(). -> Option B
  4. Quick Check:

    OVER() requires parentheses [OK]
Quick Trick: Always use parentheses after OVER keyword [OK]
Common Mistakes:
  • Omitting parentheses in OVER()
  • Thinking COUNT(*) can't be window function
  • Assuming window functions require GROUP BY

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes