Bird
0
0

Which of the following is the correct syntax to assign row numbers partitioned by department and ordered by salary?

easy📝 Syntax Q3 of 15
SQL - Window Functions Fundamentals
Which of the following is the correct syntax to assign row numbers partitioned by department and ordered by salary?
AROW_NUMBER() PARTITION BY department ORDER BY salary
BROW_NUMBER() OVER (ORDER BY salary PARTITION BY department)
CROW_NUMBER() ORDER BY salary PARTITION BY department
DROW_NUMBER() OVER (PARTITION BY department ORDER BY salary)
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct syntax for ROW_NUMBER()

    The correct syntax uses OVER (PARTITION BY ... ORDER BY ...) to partition and order rows.
  2. Step 2: Check each option

    ROW_NUMBER() OVER (PARTITION BY department ORDER BY salary) correctly places PARTITION BY before ORDER BY inside OVER(). Other options have incorrect order or missing OVER keyword.
  3. Final Answer:

    ROW_NUMBER() OVER (PARTITION BY department ORDER BY salary) -> Option D
  4. Quick Check:

    Correct syntax = ROW_NUMBER() OVER (PARTITION BY ... ORDER BY ...) [OK]
Quick Trick: Use OVER (PARTITION BY ... ORDER BY ...) with ROW_NUMBER() [OK]
Common Mistakes:
  • Omitting OVER keyword
  • Swapping ORDER BY and PARTITION BY order
  • Using PARTITION BY outside OVER()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes