title: Summing data into pivot style in same table with different predicate
body: <p>I have this data:</p>
  
  <pre><code>procedure     proc_time     proc_old_new
  =========     =========     ============
  Proc1                 3     Old
  Proc2                 5     Old
  Proc1                 2     New
  Proc3                 4     Old
  Proc3                 6     New
  Proc2                 3     Old
  Proc3                 8     New
  </code></pre>
  
  <p>And want to display it like this:</p>
  
  <pre><code>procedure     Old           new            total   Avg
  =========     =========     ============   =====   ===
  Proc1                 3                2       5   2.5
  Proc2                 8                        8   8
  Proc3                 4               14      18   9
  </code></pre>
  
  <p>I have tried various different methods such as a pivot but couldn't work out how to create this as a pivot. I have done a simpler pivot before but this one is a bit of a struggle, especially trying to work out how to sum the different parts and combine them for the old and new procedures, and put old and new in different columns.</p>
  
  <p>appreciate any help or pointers on this</p>
  
  <p>Thanks</p>
  
  <p>Andrew</p>
  
  <p>Update: New Data Display for further ideas about calculating average:</p>
  
  <pre><code>   Procedure        Intermediate      New       Old      Total   avg
     Proc1                       6        0         0        6     2.000000
     Proc2                      74       13         0       87     29.000000
     Proc3                      29        0         0       29     9.666666
     Proc4                      16        0         0       16     5.333333
  </code></pre>
  
  <p>So in line 1 I would want the average to be 6 instead of divided by 3, effectively divided by 1. Line 2 total divided by 3 etc. Would I be able to do a dynamic denominator for an average calculation? </p>