Hubert-Dudek
Databricks MVP

yes indeed it looks like a bug with LAST_VALUE,

Min gives correct results:

image.png 

Max hmm only when desc is specified (shouldn't affect as max is max but only with descending sorting it works as should be):

image.png 

for last_value is exactly like on your example (so nothing helps - I tried many ways).

@Kaniz Fatma​ maybe someone from inside databricks could look at it


My blog: https://databrickster.medium.com/