diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 6d063c4a05..078a8477af 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -559,7 +559,7 @@ class SQLCompiler: subselect, subparams = select_clone.as_sql(self, self.connection) sub_selects.append(subselect) sub_params.extend(subparams) - return 'SELECT %s FROM (%s) AS subquery' % ( + return 'SELECT %s FROM (%s) subquery' % ( ', '.join(sub_selects), ' '.join(result), ), sub_params + params