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?
- A.ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
- B.RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROWCorrect answer
- C.ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
- 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
- What is the primary difference between using a standard aggregate function with GROUP BY and using a window function in SQL?
- Consider the following query: SELECT employeeid, departmentid, salary, ROWNUMBER() OVER (PARTITION BY departmentid ORDER BY salary DESC) as…
- Which ranking window function assigns the same rank to identical values with no gaps in ranking sequence, meaning if two rows share rank 1,…
- Explain the difference between the ROWS and RANGE framing clauses in SQL window functions.
Practise more SQL
Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.
Start practising freeFree to start · No credit card needed