Return boundary values within a window frame.
Section: Lag, Lead, and Value Navigation
Use FIRST_VALUE and LAST_VALUE
sql
sql
SELECT customer_id, order_id, amount,
FIRST_VALUE(amount) OVER (PARTITION BY customer_id ORDER BY created_at) AS first_order_amount
FROM orders;Explanation
Window frame details affect LAST_VALUE behavior in some dialects.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Lag, Lead, and Value Navigation