title: Why are aggregate functions not allowed in where clause
body: <p>I am looking for clarification on this. I am writing two queries below:</p>
  
  <p>We have a table of employee name with columns ID , name , salary </p>
  
  <pre><code>  1.  Select name from employee 
      where sum(salary) &gt; 1000 ;
  
    2.  Select name from employee 
      where substring_index(name,' ',1) = 'nishant' ;
  </code></pre>
  
  <p>Query 1 doesn't work but Query 2 does work. From my development experience, I feel the possible explanation to this is:</p>
  
  <blockquote>
    <p>The sum() works on a set of values specified in the argument. Here
    'salary' column is passed , so it must add up all the values of this
    column. But inside where clause, the records are checked one by one ,
    like first record 1 is checked for the test and so on. Thus
    sum(salary) will not be computed as it needs access to all the column
    values and then only it will return a value.</p>
  </blockquote>
  
  <p>Query 2 works as substring_index() works on a single value and hence here it works on the value supplied to it. </p>
  
  <p>Can you please validate my understanding.</p>