You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CREATEtablexy (x intprimary key, y int, unique index y_idx(y));
insert into xy values (1,0), (2,1), (0,2), (3,3);
select y as z from xy group by (y) havingAVG(z) >0;
column "z" could not be found in any table in scope.
When resolving references in aggregate expressions, MySQL prefers binding to table columns over SELECT aliases. But it can still bind to a SELECT alias if no table column matches. The above example should work by binding z to the y as z alias in the SELECT.