#159250·elasticsearch

SQL: SUM over an aggregate alias can fail with an internal server error

Author: bpinteaCreated Sep 14, 2026Updated Sep 17, 2026
Labels>bug:Analytics/SQLTeam:Analyticsv9.6.0

Description

SQL queries that apply SUM to an aggregate alias in HAVING or ORDER BY can fail during optimization or planning.

SELECT SUM(int) AS s, AVG(int)
FROM test
HAVING SUM(s) > 10

The alias is inlined as SUM(int), producing an internal expression equivalent to SUM(SUM(int)).