Index: django/db/models/sql/query.py
===================================================================
--- django/db/models/sql/query.py	(wersja 13992)
+++ django/db/models/sql/query.py	(kopia robocza)
@@ -333,10 +333,10 @@
         if not self.aggregate_select:
             return {}
 
-        # If there is a group by clause, aggregating does not add useful
-        # information but retrieves only the first row. Aggregate
+        # If there is a group by or limit clause, aggregating does not add
+        # useful information but retrieves only the first row. Aggregate
         # over the subquery instead.
-        if self.group_by is not None:
+        if self.group_by is not None or self.low_mark or self.high_mark:
             from subqueries import AggregateQuery
             query = AggregateQuery(self.model)
 
@@ -390,15 +390,17 @@
             obj = AggregateQuery(obj.model)
             obj.add_subquery(subquery, using=using)
 
+        low_mark, high_mark = self.low_mark, self.high_mark
+        obj.clear_limits()
         obj.add_count_column()
         number = obj.get_aggregation(using=using)[None]
 
         # Apply offset and limit constraints manually, since using LIMIT/OFFSET
         # in SQL (in variants that provide them) doesn't change the COUNT
         # output.
-        number = max(0, number - self.low_mark)
-        if self.high_mark is not None:
-            number = min(number, self.high_mark - self.low_mark)
+        number = max(0, number - low_mark)
+        if high_mark is not None:
+            number = min(number, high_mark - low_mark)
 
         return number
 
@@ -920,7 +922,8 @@
                     aggregate.name, field_name, field_name))
         elif ((len(field_list) > 1) or
             (field_list[0] not in [i.name for i in opts.fields]) or
-            self.group_by is None or
+            (self.group_by is None and 
+             (not self.low_mark and not self.high_mark)) or
             not is_summary):
             # If:
             #   - the field descriptor has more than one part (foo__bar), or
Index: tests/modeltests/aggregation/tests.py
===================================================================
--- tests/modeltests/aggregation/tests.py	(wersja 13992)
+++ tests/modeltests/aggregation/tests.py	(kopia robocza)
@@ -17,6 +17,19 @@
         vals = Author.objects.aggregate(Avg("age"))
         self.assertEqual(vals, {"age__avg": Approximate(37.4, places=1)})
 
+    def test_slice_aggregate(self):
+        vals = Author.objects.all()[0:2].aggregate(Avg("age"))
+        self.assertEqual(vals, {"age__avg": Approximate(34.5, places=1)})
+        
+    def test_slice_annotate_aggregate(self):
+        vals = Author.objects.all()[0:2].annotate().aggregate(Avg("age"))
+        self.assertEqual(vals, {"age__avg": Approximate(34.5, places=1)})
+
+    def test_join_annotate_aggregate(self):
+        vals = Book.objects.all().annotate().aggregate(Max("authors__age"))
+        self.assertEqual(len(vals), 1)
+        self.assertEqual(vals["authors__age__max"], 57)
+        
     def test_multiple_aggregates(self):
         vals = Author.objects.aggregate(Sum("age"), Avg("age"))
         self.assertEqual(vals, {"age__sum": 337, "age__avg": Approximate(37.4, places=1)})
