hard20 pts · first answer countssqlwindow-functions
LAST_VALUE returns the current row
prices has (d, price): (1, 10), (2, 12), (3, 15). A developer expects every row to show the latest price, 15. What does the query actually return for d = 1, 2, 3?
SELECT d, LAST_VALUE(price) OVER (ORDER BY d) AS latest FROM prices ORDER BY d;
Discussion 0
Join free to post in the discussion.
Related questions
- Purpose of a primary keyData Engineer
- Row count of a LEFT JOINData Engineer
- Filtering with = NULLData Engineer
- COUNT(*) vs COUNT(column)Data Engineer
- Filtering groups with HAVINGData Engineer
- Adding a number to NULLData Engineer
- Orders pointing to missing customersData Engineer
- Upserting into a target tableData Engineer