When would you use offset functions like LAG() and LEAD()? Give an example of an analytical problem they solve.
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: easy
Interview Round: Other
Overview: Asks when to use the SQL window functions LAG and LEAD and what kind of analytical problem they solve, such as comparing a row with the one before it. Tests window ordering and partitioning, edge cases at partition boundaries, and the self-join alternative.