title: How to ignore nulls in PostgreSQL window functions? or return the next non-null value in a column
body: <p>Lets say I have the following table:</p>
  
  <pre><code> | User_id |   COL1   | COL2 |
   +---------+----------+------+
   | 1       |          | 1    |
   | 1       |          | 2    | 
   | 1       |   2421   |      | 
   | 1       |          | 1    | 
   | 1       |   3542   |      | 
   | 2       |          | 1    |
  </code></pre>
  
  <p>I need another column indicating the next non-null COL1 value for each row, so the result would look like the below:</p>
  
  <pre><code> | User_id |   COL1   | COL2 | COL3 |
   +---------+----------+------+------
   | 1       |          | 1    | 2421 |
   | 1       |          | 2    | 2421 |
   | 1       |   2421   |      |      |
   | 1       |          | 1    | 3542 |
   | 1       |   3542   |      |      |
   | 2       |          | 1    |      |
  </code></pre>
  
  <hr>
  
  <pre><code>SELECT 
  first_value(COL1 ignore nulls) over (partition by user_id order by COL2 rows unbounded following) 
  FROM table;
  </code></pre>
  
  <hr>
  
  <p>would work but I'm using PostgreSQL which doesn't support the ignore nulls clause.</p>
  
  <p>Any suggested workarounds?</p>