Bird
0
0

Which of the following is the correct syntax to specify a window frame from 2 rows before to current row using ROWS BETWEEN?

easy📝 Syntax Q12 of 15
SQL - Window Functions Fundamentals
Which of the following is the correct syntax to specify a window frame from 2 rows before to current row using ROWS BETWEEN?
AROWS BETWEEN 2 PRECEDING AND CURRENT ROW
BROWS BETWEEN CURRENT ROW AND 2 PRECEDING
CROWS BETWEEN 2 FOLLOWING AND CURRENT ROW
DROWS BETWEEN CURRENT ROW AND 2 FOLLOWING
Step-by-Step Solution
Solution:
  1. Step 1: Understand frame boundaries order

    The syntax is ROWS BETWEEN X AND Y where X is the start and Y is the end of the frame.
  2. Step 2: Identify correct order for 2 rows before to current

    Since 2 rows before is the start and current row is the end, it must be ROWS BETWEEN 2 PRECEDING AND CURRENT ROW.
  3. Final Answer:

    ROWS BETWEEN 2 PRECEDING AND CURRENT ROW -> Option A
  4. Quick Check:

    Start to end order matters = A [OK]
Quick Trick: Start boundary comes first, then end boundary in ROWS BETWEEN [OK]
Common Mistakes:
  • Reversing the order of boundaries
  • Using FOLLOWING instead of PRECEDING incorrectly
  • Omitting CURRENT ROW keyword

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes