title: Difference between two rows in Spark dataframe
body: <p>I created a dataframe in Spark, by groupby column1 and date and calculated the amount.</p>
  
  <pre><code>val table = df1.groupBy($"column1",$"date").sum("amount")
  </code></pre>
  
  <pre class="lang-none prettyprint-override"><code>Column1 |Date   |Amount
  A   |1-jul  |1000
  A   |1-june |2000
  A   |1-May  |2000
  A   |1-dec  |3000
  A   |1-Nov  |2000
  B   |1-jul  |100
  B   |1-june |300    
  B   |1-May  |400
  B   |1-dec  |300
  </code></pre>
  
  <p>Now, I want to add new column, with difference between amount of any two dates from the table.</p>