Bird
0
0

Find the mistake in this query:

medium📝 Debug Q7 of 15
PostgreSQL - Window Functions in PostgreSQL
Find the mistake in this query:
SELECT employee, salary, ROW_NUMBER() OVER w
FROM employees
WINDOW w AS (PARTITION BY department ORDER salary DESC)
AMissing BY keyword after ORDER
BROW_NUMBER() cannot be used with named windows
CWINDOW clause must not include PARTITION BY
DORDER BY cannot be combined with PARTITION BY
Step-by-Step Solution
Solution:
  1. Step 1: Review WINDOW clause syntax

    ORDER must be followed by BY keyword: ORDER BY salary DESC.
  2. Step 2: Check other parts

    ROW_NUMBER() works with named windows; PARTITION BY and ORDER BY can be combined.
  3. Final Answer:

    Missing BY keyword after ORDER -> Option A
  4. Quick Check:

    ORDER BY required, not just ORDER [OK]
Quick Trick: Use ORDER BY, not ORDER alone in WINDOW clause [OK]
Common Mistakes:
  • Writing ORDER instead of ORDER BY
  • Thinking ROW_NUMBER() disallowed with windows
  • Believing PARTITION BY and ORDER BY can't combine

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes