title: Multiple aggregate calculations using Group by
body: <p>I have a dataset, df1, where I would like to:</p>
  <ol>
  <li><strong>Take the average of the TotalB column based upon grouping the TotalB column</strong>.</li>
  <li>I would then like to <strong>take this new column and subtract the free value to obtain the Used value</strong></li>
  </ol>
  <p>df1</p>
  <pre><code>date        name    rack    TotalB  freeB   
  11/20/2020  a       yes     11      5   
  11/20/2020  a       yes     10      5   
  11/20/2020  a       yes     12      5   
  11/20/2020  a       yes     10      5   
  11/20/2020  b       no      5       2   
  11/20/2020  b       no      5       2   
  11/20/2020  b       no      6       2   
  </code></pre>
  <p><strong>Desired Outcome</strong></p>
  <pre><code>date        name    rack    TotalB  freeB   UsedB
  11/20/2020  a       yes     10.75       5    5.75
  11/20/2020  b       no      5.33        2    3.33
  </code></pre>
  <p><strong>What I am doing:</strong></p>
  <pre><code>SELECT AVG(TotalB) AS AVG_TotalB, date, name, rack, TotalB, freeB, (AVG_TotalB - freeB) AS UsedB
  FROM df1 
  GROUP BY rack
  </code></pre>
  <p>Any suggestion will be helpful.</p>