assertQuery("select-choose b from (select-group-by [sum(b) b] a, sum(b) b from (select [b] from trips) union all select-group-by [avg(d) b] c, avg(d) b from (select [d] from trips))",
assertQuery("select-choose b from (select-group-by [sum(b) b, a] a, sum(b) b from (select [b, a] from trips) union all select-group-by [avg(d) b, c] c, avg(d) b from (select [d, c] from trips))",
"select b from (select a, sum(b) b from trips union all select c, avg(d) b from trips)",