result.setAlias(pTableAlias);
addAktenId(result.getOn(), pAkteReference, result);
addEQ(result, result.getOn(), dbBeteiligte.getColumn("aFilter"), pFilter);
BooleanConstraint bc = result.getOn().createEQ();
Function f = pAkteReference.getStatement().createFunction("UPPER");
f.addPart(result.newColumnReference(dbBeteiligte.getColumn("aName")));
bc.addPart(f);
SelectStatement minStatement = sqlFactory.newSelectStatement();
minStatement.setTable(dbBeteiligte);
SelectTableReference minTableRef = minStatement.getSelectTableReference();
minTableRef.setAlias(pTableAlias + "min");
BooleanConstraint bc2 = minStatement.getWhere().createEQ();
bc2.addPart(result.newColumnReference(dbBeteiligte.getColumn("aAktenId")));
bc2.addPart(minTableRef.newColumnReference(dbBeteiligte.getColumn("aAktenId")));
bc2 = minStatement.getWhere().createEQ();
bc2.addPart(minTableRef.newColumnReference(dbBeteiligte.getColumn("aFilter")));
bc2.addPart(pFilter);
f = pAkteReference.getStatement().createFunction("MIN");
Function f2 = pAkteReference.getStatement().createFunction("UPPER");
f.addPart(f2);
f2.addPart(minTableRef.newColumnReference(dbBeteiligte.getColumn("aName")));
VirtualColumn vc = new VirtualColumn("MIN", Column.Type.VARCHAR);
vc.setValue(f);
minStatement.addResultColumn(vc);
bc.addPart(minStatement);