I have a trouble using LAST_VALUE()
window function in Google BigQuery.
In my understanding, the following two columns should return the same results, but actually they return different results and it seems the one with FIRST_VALUE()
is correct.
SELECT
FIRST_VALUE(status) OVER (PARTITION BY userId ORDER BY timestamp DESC),
LAST_VALUE(status) OVER (PARTITION BY userId ORDER BY timestamp ASC)
FROM
[table]
Did I make any mistake?