Bird
0
0

Find the error in this query snippet:

medium📝 Debug Q7 of 15
SQL - Window Functions Fundamentals
Find the error in this query snippet:

SUM(value) OVER (ORDER BY id ROWS BETWEEN 3 FOLLOWING AND CURRENT ROW)
AFrame start is after frame end, invalid order
BORDER BY cannot be used with ROWS BETWEEN
CSUM cannot be used with window frames
D3 FOLLOWING is not a valid offset
Step-by-Step Solution
Solution:
  1. Step 1: Check frame boundaries order

    The frame must start with a smaller offset and end with a larger offset relative to the current row.
  2. Step 2: Analyze given frame

    Here, frame starts at 3 FOLLOWING (offset +3) and ends at CURRENT ROW (offset 0), which reverses the order and is invalid.
  3. Final Answer:

    Frame start is after frame end, invalid order -> Option A
  4. Quick Check:

    Frame start must be before frame end [OK]
Quick Trick: Frame start offset must be <= frame end offset [OK]
Common Mistakes:
  • Reversing frame start and end
  • Misunderstanding offsets
  • Thinking ORDER BY disallows ROWS BETWEEN

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes