Here is more simple test suite:
CREATE TABLE t1 (a int, b int); insert into t1 values (1,1),(0,0);
CREATE TABLE t2 (c int); insert into t2 values (1),(2);
select sum(a),(select sum(c) from t2 where table1.b) as sub from t1 as table1 group by sub;
Here is more simple test suite:
CREATE TABLE t1 (a int, b int);
insert into t1 values (1,1),(0,0);
CREATE TABLE t2 (c int);
insert into t2 values (1),(2);
select sum(a),(select sum(c) from t2 where table1.b) as sub
from t1 as table1 group by sub;