Program: 95940
Project: 95940
Buggy source:
/** 
 * Create a sum-up query that sum the results from all tier permutations
 * @param subquery
 * @return select query that sum all the tier results
 */
SelectQuery sumUpTierGroup(SelectQuery subquery,AggMeta aggMeta,Map<Integer,String> multipleTierTableTierInfo){
  List<String> aggAlias=aggMeta.getAggAlias();
  List<String> groupby=new ArrayList<>();
  List<SelectItem> newSelectlist=new ArrayList<>();
  for (  SelectItem sel : subquery.getSelectList()) {
    if (sel instanceof AliasedColumn) {
      if (aggAlias.contains(((AliasedColumn)sel).getAliasName())) {
        newSelectlist.add(new AliasedColumn(ColumnOp.sum(new BaseColumn(TIER_CONSOLIDATED_TABLE_ALIAS,((AliasedColumn)sel).getAliasName())),((AliasedColumn)sel).getAliasName()));
      }
 else       if (aggMeta.getMaxminAggAlias().keySet().contains(((AliasedColumn)sel).getAliasName())) {
        String opType=aggMeta.getMaxminAggAlias().get(((AliasedColumn)sel).getAliasName());
        newSelectlist.add(new AliasedColumn(new ColumnOp(opType,new BaseColumn(TIER_CONSOLIDATED_TABLE_ALIAS,((AliasedColumn)sel).getAliasName())),((AliasedColumn)sel).getAliasName()));
      }
 else {
        if (!multipleTierTableTierInfo.values().contains(((AliasedColumn)sel).getAliasName())) {
          newSelectlist.add(new AliasedColumn(new BaseColumn(TIER_CONSOLIDATED_TABLE_ALIAS,((AliasedColumn)sel).getAliasName()),((AliasedColumn)sel).getAliasName()));
          groupby.add(((AliasedColumn)sel).getAliasName());
        }
      }
    }
  }
  subquery.setAliasName(TIER_CONSOLIDATED_TABLE_ALIAS);
  SelectQuery query=SelectQuery.create(newSelectlist,subquery);
  for (  String group : groupby) {
    query.addGroupby(new AliasReference(group));
  }
  return query;
}

Fixed version (ground truth):
/** 
 * Create a sum-up query that sum the results from all tier permutations
 * @param subquery
 * @return select query that sum all the tier results
 */
private SelectQuery sumUpTierGroup(SelectQuery subquery,AggMeta aggMeta,Map<Integer,String> multipleTierTableTierInfo){
  List<String> aggAlias=aggMeta.getAggAlias();
  List<String> groupby=new ArrayList<>();
  List<SelectItem> newSelectlist=new ArrayList<>();
  for (  SelectItem sel : subquery.getSelectList()) {
    if (sel instanceof AliasedColumn) {
      if (aggAlias.contains(((AliasedColumn)sel).getAliasName())) {
        newSelectlist.add(new AliasedColumn(ColumnOp.sum(new BaseColumn(TIER_CONSOLIDATED_TABLE_ALIAS,((AliasedColumn)sel).getAliasName())),((AliasedColumn)sel).getAliasName()));
      }
 else       if (aggMeta.getMaxminAggAlias().keySet().contains(((AliasedColumn)sel).getAliasName())) {
        String opType=aggMeta.getMaxminAggAlias().get(((AliasedColumn)sel).getAliasName());
        newSelectlist.add(new AliasedColumn(new ColumnOp(opType,new BaseColumn(TIER_CONSOLIDATED_TABLE_ALIAS,((AliasedColumn)sel).getAliasName())),((AliasedColumn)sel).getAliasName()));
      }
 else {
        if (!multipleTierTableTierInfo.values().contains(((AliasedColumn)sel).getAliasName())) {
          newSelectlist.add(new AliasedColumn(new BaseColumn(TIER_CONSOLIDATED_TABLE_ALIAS,((AliasedColumn)sel).getAliasName()),((AliasedColumn)sel).getAliasName()));
          groupby.add(((AliasedColumn)sel).getAliasName());
        }
      }
    }
  }
  subquery.setAliasName(TIER_CONSOLIDATED_TABLE_ALIAS);
  SelectQuery query=SelectQuery.create(newSelectlist,subquery);
  for (  String group : groupby) {
    query.addGroupby(new AliasReference(group));
  }
  return query;
}