🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Window Functions: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. Salaries 100, 90, 90, 80 ordered DESC. What RANK does 80 get?
  2. Q2. Same salaries. What DENSERANK does 80 get?
  3. Q3. What does PARTITION BY do inside OVER()?
  4. Q4. Which function returns the value from the previous row?
  5. Q5. Why can't you write WHERE ROWNUMBER() OVER (...) = 1?
  6. Q6. In the company table, what is the 4th highest DISTINCT salary (DENSERANK = 4)?
  7. Q7. LEAD(salary) OVER (ORDER BY joined) — what does it show for Om, who joined just before Arjun?
  8. Q8. How many rows does SELECT name, AVG(salary) OVER (PARTITION BY deptid) FROM employees return for the 7 employees?
  9. Q9. You need the top 2 earners in every department. Which filter goes in the outer query?
  10. Q10. Why add a tie-breaker such as name to ROWNUMBER() OVER (ORDER BY salary DESC, name)?