Bird
0
0

Which of the following is the correct syntax to assign a rank using DENSE_RANK() ordered by salary descending?

easy📝 Syntax Q3 of 15
SQL - Window Functions Fundamentals
Which of the following is the correct syntax to assign a rank using DENSE_RANK() ordered by salary descending?
ASELECT employee, RANK() DENSE_RANK ORDER BY salary DESC FROM employees;
BSELECT employee, DENSE_RANK() OVER (ORDER BY salary DESC) AS rank FROM employees;
CSELECT employee, DENSE_RANK BY salary DESC FROM employees;
DSELECT employee, DENSE_RANK(salary DESC) FROM employees;
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct window function syntax

    DENSE_RANK() requires OVER clause with ORDER BY inside parentheses.
  2. Step 2: Check each option for syntax correctness

    SELECT employee, DENSE_RANK() OVER (ORDER BY salary DESC) AS rank FROM employees; uses correct syntax: DENSE_RANK() OVER (ORDER BY salary DESC).
  3. Final Answer:

    SELECT employee, DENSE_RANK() OVER (ORDER BY salary DESC) AS rank FROM employees; -> Option B
  4. Quick Check:

    Correct DENSE_RANK syntax = D [OK]
Quick Trick: Window functions need OVER() with ORDER BY inside [OK]
Common Mistakes:
  • Omitting OVER() clause
  • Misplacing ORDER BY outside OVER()
  • Mixing RANK and DENSE_RANK keywords

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes