Window Functions · Question 1 · Easy

Window Functions question 1

Three students are tied on the highest marks. Which function, used with OVER (ORDER BY marks DESC), still gives them the three different numbers 1, 2 and 3?

  1. RANK()
  2. DENSE_RANK()
  3. ROW_NUMBER()
  4. COUNT(*)
Answer and explanation

Answer: C. ROW_NUMBER()

Explanation: ROW_NUMBER() numbers rows 1, 2, 3, ... with no repeats, breaking ties arbitrarily. RANK() and DENSE_RANK() would give all three tied students the number 1.

Next: Table DailySales: day_no | amount 1 | 100 2 | 250 3 | 150 4 | 300 What does…

Practise window functions

Try a fresh set of window functions questions with an explanation after every answer, free and without signing up: Window Functions practice. Or sit a full placement mock test.

More window functions questions

More sql practice

NULL Handling · SQL Functions & CASE · UNION, INTERSECT & EXCEPT · Tables, Keys & Constraints · DML & Transactions · SELECT, WHERE & ORDER BY · SQL Joins · Aggregates & GROUP BY

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge