* </pre>
*/
private JoinReference getFirstRowStatement2(String pFilter, TableReference pAkteReference,
SelectTableReference pJoinReference,
String pTableAlias) {
Column aName = dbBeteiligte.getColumn("aName");
Column aVorname = dbBeteiligte.getColumn("aVorname");
Column aAktenId = dbBeteiligte.getColumn("aAktenId");
Column aFilter = dbBeteiligte.getColumn("aFilter");
SelectStatement st = sqlFactory.newSelectStatement();
st.setTable(dbBeteiligte);
SelectTableReference ref = st.getSelectTableReference();
VirtualColumn num = new VirtualColumn("NUM", Column.Type.INTEGER);
num.setValue("COUNT(*) OVER (PARTITION BY " + aAktenId.getName() + ")");
st.addResultColumn(num);
VirtualColumn minAName = new VirtualColumn("MINANAME", Column.Type.VARCHAR);
minAName.setValue("MIN(UPPER(" + aName.getName() + ")) OVER (PARTITION BY " +
aAktenId.getName() + ")");
st.addResultColumn(minAName);
VirtualColumn minAVorname = new VirtualColumn("MINAVORNAME", Column.Type.VARCHAR);
minAVorname.setValue("MIN(UPPER(NVL(" + aVorname.getName() +
", ' '))) OVER (PARTITION BY " +
aAktenId.getName() + ", UPPER(" + aName.getName() +
"))");
st.addResultColumn(minAVorname);
st.addResultColumn(ref.newColumnReference(aName));
st.addResultColumn(ref.newColumnReference(aVorname));
st.addResultColumn(ref.newColumnReference(aAktenId));
BooleanConstraint bc = st.getWhere().createEQ();
bc.addPart(st.getTableReference().newColumnReference(aFilter));
bc.addPart(pFilter);
Table t = st.createView((Table.Name) null);
SelectStatement st2 = sqlFactory.newSelectStatement();
st2.setTable(t);
SelectTableReference ref2 = st2.getSelectTableReference();
st2.addResultColumn(ref2.newColumnReference(t.getColumn("NUM")));
Column aName2 = t.getColumn(aName.getName());
st2.addResultColumn(ref2.newColumnReference(aName2));
Column aVorname2 = t.getColumn(aVorname.getName());
st2.addResultColumn(ref2.newColumnReference(aVorname2));
st2.addResultColumn(ref2.newColumnReference(t.getColumn(aAktenId.getName())));
bc = st2.getWhere().createEQ();
bc.addPart(ref2.newColumnReference(t.getColumn("MINAVORNAME")));