- Is the following possible according to standard(!) SQL?
- What minimal changes should be neccessary in order to be conforming to the standard (if it wasn't already)?
- It works as expected in MySQL, iff the first row has the maximum value for NumberOfPages.
SELECT *
FROM Book
HAVING NumberOfPages = MAX(NumberOfPages)
The following is written in the standard:
HAVING <search condition>
- Let G be the set consisting of every column referenced by a <column reference> contained in the <group by clause>.
- Each column reference directly contained in the <search condition> shall be one of the following:
- An unambiguous reference to a column that is functionally dependent on G.
- An outer reference.
Can somebody explain me, why it should be possible according to the standard?
In MySQL, it perfectly works.