title: SQL Comparing columns and calculating the difference
body: <p>I'm using Oracle 11gR2</p>
  
  <p>I have a table for example:</p>
  
  <pre><code>ProductName   |   Volume   |   Date
  -------------------------------------------
  ProdA         |   1000     |   11-Oct-2013
  ProdA         |   2000     |   16-Oct-2013
  ProdB         |   500      |   12-Oct-2013
  
  ProdA         |   200      |   11-Nov-2013
  ProdB         |   100      |   16-Nov-2013
  ProdB         |   300      |   12-Nov-2013
  </code></pre>
  
  <p>What i want to do is total the volume for each product and then compare the volume across 2 months and have a calculated field working out the difference, so i would end up with:</p>
  
  <pre><code>ProductName   |   VolumeCurrentMonth   |   VolumePrevMonth   |   Difference
  -------------------------------------------
  ProdA         |   200                  |   3000              |    -2800
  ProdB         |   400                  |   500               |    -100
  </code></pre>
  
  <p>My code is no where near the fulfilling the requirement but i'll post it anyway:</p>
  
  <pre><code>Select ProductName, sum(Volume), to_char(Date, 'Month') as Current_Month, to_char(run_date, 'Month') as PY_Month
  from Sales
  where Date is not null
  group by ProductName, Date;
  </code></pre>