From the standard (bold added from emphasis)
1) Let HC be the having clause. Let TE be the table expression that immediately contains HC. If TE does not immediately contain a group by clause, then “GROUP BY ()” is implicit. Let T be the descriptor of the table defined by the GBC immediately contained in TE and let R be the result of GBC.
With the implicit group by clause, the outer reference can access the TE columns.
However, the certification to these standards is very much a self-certification these days, and the example you gave would not work across all of the main RDBMS providers.