title: Can I write a condition on a single column name of a relation in HAVING clause
body: <p>Considering the following relational schema</p>
  
  <pre><code>customers(id, name, age, address, salary)
  </code></pre>
  
  <p>I tried a query </p>
  
  <pre><code>SELECT SUM(salary), age FROM customers             
  GROUP BY age HAVING age &gt; 23 ;                    ...(1)
  </code></pre>
  
  <p>I was surprised to see that it worked fine and that I could write a single column condition also in HAVING clause.</p>
  
  <p>Even this is also working</p>
  
  <pre><code>SELECT SUM(salary), age FROM customers
  GROUP BY age, salary HAVING age &gt; 23 AND salary &gt;2000;   ...(2)
  </code></pre>
  
  <p>Otherwise, I should have written it like this :  (using WHERE clause)</p>
  
  <pre><code>SELECT SUM(salary), age FROM customers
  WHERE age &gt; 23 GROUP BY age;                       ...(3)
  </code></pre>
  
  <p>And </p>
  
  <pre><code>SELECT SUM(salary), age FROM customers
  WHERE age &gt; 23 AND salary &gt;2000 GROUP BY age, salary ;    ..(4)
  </code></pre>
  
  <p>But when I tried with more combinations I found that </p>
  
  <blockquote>
    <p>that column name must be present in GROUP BY clause also on which condition is applied in HAVING clause.</p>
  </blockquote>
  
  <p>Am I correct or is it possible to write a single column condition in HAVING clause in any other way also ?</p>
  
  <p>Why is it working because I had earlier studied that we can write only conditions on Aggregate functions in HAVING clause.</p>