title: SQL Subtract Column Values Based on Second Column Value with Group By Statement
body: <p>I have an SQL statement that looks so:</p>
  
  <pre><code>select FY_CD, PD_NO, INPUT, SUM(HOURS) 
  from LABOR_TABLE
  group by PD_NO, INPUT;
  </code></pre>
  
  <p>Returning this:</p>
  
  <pre><code>FY_CD|PD_NO| INPUT |    HOURS
  
  2008    1   Actuals     61000
  2008    1   Baseline    59000
  2008    2   Actuals     54000
  2008    2   Baseline    59000
  2008    3   Actuals     60000
  2008    3   Baseline    70000
  </code></pre>
  
  <p>I'm trying to figure out how to subtract the Actual values from the Baseline values for each period, returning the following:</p>
  
  <pre><code>FY_CD|PD_NO| INPUT |    HOURS
  
  2008    1   Variance    2000
  2008    2   Variance    -5000
  2008    3   Variance    -10000
  </code></pre>
  
  <p>Any help is appreciated.</p>