}
CompareCriteria cc = new CompareCriteria();
cc.setLeftExpression(criteria.getLeftExpression());
Query q = createInlineViewQuery(new GroupSymbol("X"), criteria.getCommand(), metadata, criteria.getCommand().getProjectedSymbols()); //$NON-NLS-1$
SingleElementSymbol ses = q.getProjectedSymbols().get(0);
Expression expr = SymbolMap.getExpression(ses);
q.getSelect().clearSymbols();
AggregateSymbol.Type type = Type.MAX;
if (criteria.getOperator() == CompareCriteria.GT || criteria.getOperator() == CompareCriteria.GE) {
type = Type.MIN;
}
q.getSelect().addSymbol(new AggregateSymbol(ses.getName(), type.name(), false, expr));
cc.setRightExpression(new ScalarSubquery(q));
cc.setOperator(criteria.getOperator());
return rewriteCriteria(cc);
}
Expression leftExpr = rewriteExpressionDirect(criteria.getLeftExpression());
if (isNull(leftExpr)) {
return UNKNOWN_CRITERIA;
}