Skip to content

Commit

Permalink
MONDRIAN
Browse files Browse the repository at this point in the history
   Fix bug that using aggregate table with distinct count generated SQL
   with group-by clause.

[git-p4: depot-paths = "//open/mondrian/": change = 4629]
  • Loading branch information
Richard Emberson committed Dec 9, 2005
1 parent b7082f1 commit b72131a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/mondrian/rolap/agg/AggQuerySpec.java
Expand Up @@ -167,7 +167,10 @@ protected void distinctGenerateSQL(final SqlQuery outerSqlQuery) {
final String alias = "d" + i;
innerSqlQuery.addSelect(expr, alias);
outerSqlQuery.addSelect(alias);
outerSqlQuery.addGroupBy(alias);

if (! hasDistinct()) {
outerSqlQuery.addGroupBy(alias);
}
}
// add measures
// this can also add non-shared local dimension columns, which are
Expand Down Expand Up @@ -202,7 +205,9 @@ protected void nonDistinctGenerateSQL(final SqlQuery sqlQuery) {
sqlQuery.addSelect(expr, getColumnAlias(i));
}

if (isAggregate()) {
// only add a group-by clause if we are NOT doing
// a distinct count measure
if (! hasDistinct()) {
sqlQuery.addGroupBy(expr);
}
}
Expand Down

0 comments on commit b72131a

Please sign in to comment.