title: Using alias name in where clause - SQL
body: <p>I have a Summary table (data_summary) and a Summary Details table (data_summary_dtl). I'm applying the following query in data_summary_dtl table to get the </p>
  
  <blockquote>
    <p>Number of records in detail table for each record in the summary
    table,select data if count is greater than 2</p>
  </blockquote>
  
  <pre><code>select summary_gid,COUNT(summary_gid) as varCount 
  from data_summary_dtl 
  group by summary_gid; 
  </code></pre>
  
  <p>I can list the summary_id along with the count using the following query, </p>
  
  <p>Which gives fine result for me, now my question is that how can i obtain the result of records that having count greater than <code>2</code>.</p>
  
  <p>i had tried the following but not get the result as expected:</p>
  
  <pre><code>select summary_gid,COUNT(summary_gid) as varCount
  from data_summary_dtl
  where varCount &gt; 2 
  group by summary_gid; 
  
  select summary_gid,COUNT(summary_gid) as varCount 
  from data_summary_dtl
  where COUNT(summary_gid) &gt; 2
  group by summary_gid; 
  </code></pre>
  
  <p>Is there any other possibility to get the result?</p>