I thought I understood how it works but now I am confused.
I have a dataset:
id date value
1 20080101 null
2 20090101 34
3 20100101 null
Three records, from Jan 2008, 2009 and 2010. Now I want to create a new column "value2" with the latest non-null value. Basically I want a value2 column with 3 34s. I write:
select id, date, value, first_value(value) ignore nulls over (order by date desc) as value2 from table
However, I got:
id date value value2
1 20080101 null 34
2 20090101 34 34
3 20100101 null null
The last value is still null not 34. What is going wrong here?