SQL - Use Max in where clause

Assume value is an int and the following query is valid:

FROM table
WHERE attribute = value

Though MAX(expression) returns int, the following is not valid:

FROM table
WHERE attribute = MAX(expression)

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"?

This question and all comments follow the "Attribution Required."

All Answers

Answers Loading...
Leave a Reply
You must be logged in to post a answer.
About the author