title: SQL Sum with Sub Query?
body: <p>Thanks for any help in advance, I can't wrap my SQL skills around this one...
  I have two tables like this:<br/></p>
  
  <p><strong>Settings</strong></p>
  
  <blockquote>
    <p><strong>Customerid</strong> &nbsp;&nbsp;&nbsp; <strong>ViewerLimit</strong><br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;50<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;50</p>
  </blockquote>
  
  <p><strong>Distribution</strong></p>
  
  <blockquote>
    <p><strong>Customerid</strong> &nbsp;&nbsp;&nbsp; <strong>ServerIP</strong><br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stream3<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stream4<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stream3</p>
  </blockquote>
  
  <p>I want to calculate the load on each server.  A customer divides the load if they have more than one server, so here customer 1 puts a load of 25 on each server.  The result I'm trying to get is this:</p>
  
  <blockquote>
    <p><strong>ServerIP</strong> &nbsp;&nbsp;&nbsp;&nbsp; <strong>Load</strong><br>
    &nbsp;stream3 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 75<br>
    &nbsp;stream4 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25<br></p>
  </blockquote>
  
  <p>I tried to do a sum function similar to this:</p>
  
  <pre><code>sum(viewerlimit/(count # of servers)) as load group by serverip
  </code></pre>
  
  <p>But I can't do a sub query within a sum function.  There are many customers and possibly many servers per customer so it will become too complex to do manually.  I appreciate any input.</p>