Bird
0
0

Why does the LEAD function return NULL for the last row in a partition?

hard📝 Conceptual Q10 of 15
SQL - Advanced Window Functions
Why does the LEAD function return NULL for the last row in a partition?
ABecause NULL is the default value for all rows
BBecause there is no next row after the last row
CBecause the last row is excluded by default
DBecause LEAD only works on even-numbered rows
Step-by-Step Solution
Solution:
  1. Step 1: Understand LEAD behavior at partition end

    The LEAD function looks forward to the next row; if none exists, it returns NULL.
  2. Step 2: Eliminate incorrect options

    LEAD works on all rows, does not exclude last row, and NULL is not default for all rows.
  3. Final Answer:

    Because there is no next row after the last row -> Option B
  4. Quick Check:

    LEAD returns NULL when no next row exists [OK]
Quick Trick: Last row LEAD returns NULL, no next row exists [OK]
Common Mistakes:
  • Thinking LEAD skips last row
  • Assuming NULL is default for all rows
  • Believing LEAD works only on certain rows

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes