// not in having):
// SELECT 1 AS A FROM DUAL ORDER BY -A
boolean isAlias = false;
int idx = expressions.size();
if (e instanceof ExpressionColumn) {
ExpressionColumn exprCol = (ExpressionColumn) e;
String tableAlias = exprCol.getOriginalTableAliasName();
String col = exprCol.getOriginalColumnName();
for (int j = 0; j < visible; j++) {
boolean found = false;
Expression ec = expressions.get(j);
if (ec instanceof ExpressionColumn) {
ExpressionColumn c = (ExpressionColumn) ec;
found = col.equals(c.getColumnName());
if (tableAlias != null && found) {
String ca = c.getOriginalTableAliasName();
if (ca != null) {
found = tableAlias.equals(ca);
}
}
} else if (!(ec instanceof Alias)) {
continue;
} else if (tableAlias == null && col.equals(ec.getAlias())) {
found = true;
} else {
Expression ec2 = ec.getNonAliasExpression();
if (ec2 instanceof ExpressionColumn) {
ExpressionColumn c2 = (ExpressionColumn) ec2;
String ta = exprCol.getSQL();
// exprCol.getTableAlias();
String tb = c2.getSQL();
// getTableAlias();
found = col.equals(c2.getColumnName());
if (!StringUtils.equals(ta, tb)) {
found = false;
}
}
}