@@ -157,20 +157,6 @@ public String build() throws SqlParseException {
157157 }
158158 }
159159
160- // aggregators
161- if (!CollectionUtils .isEmpty (executeParam .getAggregators ())) {
162- for (AggregateOperator aggregator : executeParam .getAggregators ()) {
163- String alias ;
164- if (aggregator .getSqlOperator () == null ) {
165- alias = aggregator .getColumn ();
166- } else {
167- alias = aggregator .getSqlOperator ().name () + "(" + aggregator .getColumn () + ")" ;
168- }
169- columnAlias .put (aggregator .getColumn (), alias );
170- selectList .add (createAggNode (aggregator .getSqlOperator (), aggregator .getColumn (), alias ));
171- }
172- }
173-
174160 //group by
175161 if (!CollectionUtils .isEmpty (executeParam .getGroups ())) {
176162 for (GroupByOperator group : executeParam .getGroups ()) {
@@ -186,6 +172,20 @@ public String build() throws SqlParseException {
186172 }
187173 }
188174
175+ // aggregators
176+ if (!CollectionUtils .isEmpty (executeParam .getAggregators ())) {
177+ for (AggregateOperator aggregator : executeParam .getAggregators ()) {
178+ String alias ;
179+ if (aggregator .getSqlOperator () == null ) {
180+ alias = aggregator .getColumn ();
181+ } else {
182+ alias = aggregator .getSqlOperator ().name () + "(" + aggregator .getColumn () + ")" ;
183+ }
184+ columnAlias .put (aggregator .getColumn (), alias );
185+ selectList .add (createAggNode (aggregator .getSqlOperator (), aggregator .getColumn (), alias ));
186+ }
187+ }
188+
189189 //order
190190 if (!CollectionUtils .isEmpty (executeParam .getOrders ())) {
191191 for (OrderOperator order : executeParam .getOrders ()) {
0 commit comments