title: Using Last_Value Window Function in Redshift/PostgreSQL
body: <p>I have the following query:</p>
  
  <pre><code>select
      x.value1,
      x.value2,
      y,
      last_value(y ignore nulls)
            over (order by x.value1, x.value2 rows unbounded preceding) as val
  
  from table t
  </code></pre>
  
  <p>For the following table,</p>
  
  <pre><code>value1.x1   value2.x2    3
  value1.x2   value2.x2
  value1.x3   value2.x3    5
  value1.x4   value2.x4
  value1.x5   value2.x5
  value1.x6   value2.x6    7
  value1.x7   value2.x7
  </code></pre>
  
  <p>the query is giving the output</p>
  
  <pre><code>value1.x1   value2.x2    3     3
  value1.x2   value2.x2          3
  value1.x3   value2.x3    5     5
  value1.x4   value2.x4          5
  value1.x5   value2.x5          5
  value1.x6   value2.x6    7     7
  value1.x7   value2.x7
  </code></pre>
  
  <p>It's correctly copying the values until the very last row. I'm not sure why it's not going all the way down. Is "rows unbounded preceding" not the correct frame to use? Can someone point out my mistake? Not sure if this would apply to MySQL as well but I would be interested in such a solution as well.</p>
  
  <p>Thanks!</p>