Window Functions · SQL SQL

What is the default frame specification in a window function when an ORDER BY clause is provided, but no explicit ROWS or RANGE frame is specified?

Practice question from Window Functions (SQL SQL), with the correct answer and a step-by-step solution.

medium · MCQ · Q-E96C27

What is the default frame specification in a window function when an ORDER BY clause is provided, but no explicit ROWS or RANGE frame is specified?

  1. A.ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
  2. B.RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROWCorrect answer
  3. C.ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
  4. D.RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING

Solution

According to the SQL standard, if an ORDER BY clause is specified without an explicit frame clause, the default frame is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW. If ORDER BY is omitted, the default frame is typically RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING (or covers the entire partition).

More from Window Functions

All of Window Functions

Practise more SQL

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed