diff --git a/scope_private.go b/scope_private.go index f6f815d9..f47c8433 100644 --- a/scope_private.go +++ b/scope_private.go @@ -213,7 +213,7 @@ func (scope *Scope) selectSql() string { return "*" } sql := scope.buildSelectQuery(scope.Search.selects) - scope.Search.countingQuery = hasCountRegexp.MatchString(sql) + scope.Search.countingQuery = (len(scope.Search.group) == 0) && hasCountRegexp.MatchString(sql) return scope.buildSelectQuery(scope.Search.selects) }