title: PostgreSQL Where count condition
body: <p>I have following query in PostgreSQL:</p>
  
  <pre><code>SELECT 
      COUNT(a.log_id) AS overall_count
  FROM 
      "Log" as a, 
      "License" as b 
  WHERE 
      a.license_id=7 
  AND 
      a.license_id=b.license_id 
  AND
      b.limit_call &gt; overall_count
  GROUP BY 
      a.license_id;
  </code></pre>
  
  <p>Why do I get this error:</p>
  
  <blockquote>
    <p>ERROR:  column "overall_count" does not exist</p>
  </blockquote>
  
  <p>My table structure:</p>
  
  <pre><code>License(license_id, license_name, limit_call, create_date, expire_date)
  Log(log_id, license_id, log, call_date)
  </code></pre>
  
  <p>I want to check if a license has reached the limit for calls in a specific month.</p>