- Does the following make sense in terms of normal(!) SQL?
- What minor adjustments are required to bring something into compliance with the standard, if it isn't already?
- If the first row contains the maximum value for NumberOfPages, MySQL behaves as expected.
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?