title: Update record with previous row
body: <p>I have a situation where I need to update the records with previous row value. </p>
  
  <p>Source:</p>
  
  <pre><code>|MatId | BaseId |Flag|Pkg1| CS1
  --------------------------------
  |3001  | 3001   | 1  | 20 | 2 |
  |3002  | 3001   | 0  | 15 | 3 |
  |3003  | 3001   | 0  | 10 | 4 |
  </code></pre>
  
  <p>Here both 3001 (<code>MatID</code>) and 3001(<code>BaseID</code>) are same so <code>FLAG</code>  =1, in the next record only <code>BASEID</code> is same. The output should be <strong>only <code>PKG1</code></strong> field updated with the current row value.</p>
  
  <p>Target or output:</p>
  
  <pre><code>|MatId | BaseId|Flag|Pkg1|CS1
  ------------------------------
  |3001  | 3001  | 1  | 20 | 2|
  |3002  | 3001  | 0  | 20 | 3|
  |3003  | 3001  | 0  | 20 | 4|
  </code></pre>
  
  <p>As seen in the target above i have to update the two values in PKG1 with the value from first record 20. Also there are many columns with Pkg1, how to update all the columns with a single query?</p>
  
  <p>Any help is very much appreciated.<br>
  Thanks.</p>