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 name, DENSE_RANK(score) OVER (ORDER BY score DESC) FROM players;
ADENSE_RANK() should not have a column inside the parentheses.
BDENSE_RANK() cannot be used without PARTITION BY clause.
CORDER BY clause is missing in the OVER() clause.
DThe query is correct and will run without errors.
Step-by-Step Solution
Solution:
  1. Step 1: Check DENSE_RANK() syntax

    DENSE_RANK() does not take any arguments inside parentheses; it is called as DENSE_RANK() OVER (...).
  2. Step 2: Identify the error in the query

    The query incorrectly uses DENSE_RANK(score), which causes a syntax error.
  3. Final Answer:

    DENSE_RANK() should not have a column inside the parentheses. -> Option A
  4. Quick Check:

    DENSE_RANK() has empty parentheses [OK]
Quick Trick: Window functions have empty parentheses, column goes in ORDER BY [OK]
Common Mistakes:
  • Putting column inside DENSE_RANK()
  • Thinking PARTITION BY is mandatory
  • Omitting OVER() clause

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes