Bird
0
0

Which of the following is the correct syntax to use a window function in SQL?

easy📝 Syntax Q12 of 15
SQL - Window Functions Fundamentals
Which of the following is the correct syntax to use a window function in SQL?
ASELECT name, RANK() OVER (ORDER BY score) FROM players;
BSELECT name, RANK(score) FROM players ORDER BY score;
CSELECT name, RANK() FROM players GROUP BY score;
DSELECT name, RANK OVER (ORDER BY score) FROM players;
Step-by-Step Solution
Solution:
  1. Step 1: Recall window function syntax

    Window functions use function() OVER (PARTITION BY ... ORDER BY ...).
  2. Step 2: Check each option

    SELECT name, RANK() OVER (ORDER BY score) FROM players; correctly uses RANK() OVER (ORDER BY score). Others miss parentheses or OVER keyword.
  3. Final Answer:

    SELECT name, RANK() OVER (ORDER BY score) FROM players; -> Option A
  4. Quick Check:

    Window function syntax = function() OVER (...) [OK]
Quick Trick: Window functions always use OVER() clause [OK]
Common Mistakes:
  • Omitting parentheses after function name
  • Forgetting the OVER keyword
  • Using GROUP BY instead of window functions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes