title: alternatives to "Having"
body: <p>I have a <code>SELECT</code> statement that counts the number of instances and then saves in a variable. It has  a <code>HAVING</code> clause that does a <code>SUM</code> and a <code>COUNT</code>. However since you have to have a <code>GROUP BY</code> in order to use <em>having</em>, the <em>select</em> statement returns 4 lines that are 1 instead of the total being 4. This then doesn't save the <em>count</em> into the variable as 4 but as 1 which obviously is not what I need so I am looking for an alternative work around.</p>
  
  <pre><code>    select count(distinct p1.community) 
          from
              "Database".prospect p1
      where 
          p1.visit_date &gt;= '2013-07-01' 
          and p1.visit_date &lt;= '2013-09-30'
          and p1.division = '61'  
      group By 
          p1.community
      having 
          sum(p1.status_1) / count(p1.control_code) &gt;= .16;
  </code></pre>