SQL FIRST_VALUE() and LAST_VALUE(): why LAST_VALUE() needs an explicit window frame
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Other
Overview: Asks what the SQL window functions FIRST_VALUE() and LAST_VALUE() return and why LAST_VALUE() surprises people when no frame clause is given. Tests understanding of default window frames, ROWS versus RANGE, ties in the ORDER BY, and how to write a frame that covers the whole partition.