title: Bigquery Query: Adding a specific value to previous rows in BigQuery
body: <p>I want to create a add a specific value to rows with null value in case they have something that isn't a null value. It's something difficult to understand, but it could be easier in watching the desired output:</p>
  <p>This is my actual table:</p>
  <pre><code>DATESTAMP______________pressure__________final_date 
  2021-02-19T21:19:35_______10.12_____________null
  2021-02-19T22:19:35_______11.13_____________null
  2021-02-19T23:19:35_______10.43_____________null
  2021-02-20T00:19:35_______11.98_____________null
  2021-02-20T01:19:35_______10.21_____________null
  2021-02-20T01:40:10_______20.21_____________2021-02-20
  2021-02-24T23:11:00_______10.42_____________null
  2021-02-25T00:11:00_______10.51_____________null
  2021-02-25T00:11:00_______20.51_____________2021-02-25
  2021-02-28T11:11:12_______10.51_____________null
  2021-02-28T12:11:12_______10.52_____________null
  </code></pre>
  <p>This is mi desired table after doing the query:</p>
  <pre><code>DATESTAMP______________pressure__________final_date 
  2021-02-19T21:19:35_______10.12_____________2021-02-20
  2021-02-19T22:19:35_______11.13_____________2021-02-20
  2021-02-19T23:19:35_______10.43_____________2021-02-20
  2021-02-20T00:19:35_______11.98_____________2021-02-20
  2021-02-20T01:19:35_______10.21_____________2021-02-20
  2021-02-20T01:40:10_______20.21_____________2021-02-20
  2021-02-24T23:11:00_______10.42_____________2021-02-25
  2021-02-25T00:11:00_______10.51_____________2021-02-25
  2021-02-25T00:11:00_______20.51_____________2021-02-25
  2021-02-28T11:11:12_______10.51_____________null
  2021-02-28T12:11:12_______10.52_____________null
  </code></pre>
  <p>It doesn't matter if I have to create a new column:
  That's my query:</p>
  <pre><code>SELECT *, IF(final_date is null, LAG(final_date ) OVER (ORDER BY DATESTAMP DESC), final_date ) AS preceding FROM(
  SELECT
    * FROM my_table
  ORDER BY DATESTAMP ASC)
  ORDER BY DATESTAMP ASC
  </code></pre>
  <p>And that's the result I received in the before query:</p>
  <p>DATESTAMP______________pressure_________final_date_______preceding</p>
  <p>2021-02-19T21:19:35_______10.12_____________null_____________null</p>
  <p>2021-02-19T22:19:35_______11.13_____________null_____________null</p>
  <p>2021-02-19T23:19:35_______10.43_____________null _____________null</p>
  <p>2021-02-20T00:19:35_______11.98_____________null _____________null</p>
  <p>2021-02-20T01:19:35_______10.21_____________null_____________2021-02-20</p>
  <p>2021-02-20T01:40:10_______20.21_____________2021-02-20 ______2021-02-20</p>
  <p>2021-02-24T23:11:00_______10.42_____________null_____________null</p>
  <p>2021-02-25T00:11:00_______10.51_____________null_____________2021-02-25</p>
  <p>2021-02-25T00:11:00_______20.51_____________2021-02-25_______2021-02-25</p>
  <p>2021-02-28T11:11:12_______10.51_____________null_____________null</p>
  <p>2021-02-28T12:11:12_______10.52_____________null_____________null</p>
  <p>Can someone help me?</p>
  <p>Thanks!</p>