Why doesn't LAST_VALUE return the last value?
问题 I want to find the last value of y over an ordered partition using a query like this: SELECT x, LAST_VALUE(y) OVER (PARTITION BY x ORDER BY y ASC) FROM table But LAST_VALUE returns lots of values that aren't the last value (in this case, the largest value) of y for a given partition. Why? (In this case, MAX can be used instead of LAST_VALUE to find the largest value, but why doesn't LAST_VALUE return the max value too?) 回答1: TLDR: The query you want is: SELECT x, LAST_VALUE(y) OVER (PARTITION