diff --git a/lib/active_record_group_count/scope.rb b/lib/active_record_group_count/scope.rb index 988c71d..7104f67 100644 --- a/lib/active_record_group_count/scope.rb +++ b/lib/active_record_group_count/scope.rb @@ -4,7 +4,7 @@ module Scope module ExtensionMethods def count(*args) - scope = except(:select).select("1") + scope = except(:select).except(:distinct).select("1") scope_sql = if scope.klass.connection.respond_to?(:unprepared_statement) scope.klass.connection.unprepared_statement { scope.to_sql } else