title: SQL count(*) with having
body: <p>I have this query on oracle.</p>
  <pre><code>SELECT CBG.refs, CBG.cuo, CBG.date, CBG.nber, CG.date, CBG.conso, 
                  (SELECT COUNT(*) 
                      FROM MAD.VIN CBV
                      WHERE CBV.CUO = CBG.CUO AND 
                          CBV.NBER = CBG.NBER AND
                          CBV.DATE = CBG.DATE AND
                          CBV.REFS = CBG.REFS 
                          GROUP BY CUO , DATE , NBER , REFS )  AS COUNTS ,
                  CBG.CONSO_CONCESS AS CONCESS
                  FROM MAD.GEN CBG, MAD.CAR_GEN CG
                  WHERE CBG.cuo = CG.cuo AND 
                  CBG.CONSO_DATE IS NOT NULL AND
                  CBG.date = CG.date AND 
                  CBG.nber = CG.nber
                  HAVING COUNTS &gt; 0;
  </code></pre>
  <p>when i run this sql query it gives me an error that says: invalid identifier counts.</p>
  <p>How do we get results only if count is greater than a given parameter?</p>
  <p>Thanks.</p>