title: SQL - Using MAX in a WHERE clause
body: <p>Assume value is an int and the following query is valid:</p>
  
  <pre><code>SELECT blah
  FROM table
  WHERE attribute = value
  </code></pre>
  
  <p>Though MAX(expression) returns int, the following is not valid:</p>
  
  <pre><code>SELECT blah
  FROM table
  WHERE attribute = MAX(expression)
  </code></pre>
  
  <p>OF course the desired effect can be achieved using a subquery, but my question is why was SQL designed this way - is there some reason why this sort of thing is not allowed? Students coming from programming languages where you can always replace a data-type by a function call that returns that type find this issue confusing. Is there an explanation one can give them rather than just saying "that's the way it is"?</p>