title: How to do calculations inside sql query
body: <p>I have a Salesman table and a Sales table, I need to get a count of Salesman whose revenue was $1,000,000 based on previous quarter.</p>
  
  <p>The problem I am having is this:</p>
  
  <p>I can do a select of the Sales Table which gets every salesman, then an inner select statement where I take each salesman and find all of his sales. I need to see if all of his sales >= $1,000,000 and I don't know how/if I can do arithmetic inside the select statements to sum of the sales and see if they are >= $1m</p>
  
  <p>Here is my code:</p>
  
  <pre><code>Select count(SalesID) from Salesman SM where SM.SalesID in
  (
       Select cost from Sales where salesDate &gt;= beginQtr AND salesDate &lt;= endQtr
       //some code to add them all up and if &gt;= $1m, count that Salesman
  ); 
  </code></pre>