title: Django Rest Framework - Annotate duplicates values
body: <p>I encounter a really weird bug. When annotating 3 values (AVG, COUNT and SUM) I notice that COUNT and SUM are multiplying each other.</p>
  <p>For instance:</p>
  <p><a href="https://i.stack.imgur.com/ZucUJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZucUJ.png" alt="enter image description here" /></a></p>
  <p>The duration should be half the time and there are only 2 ratings (number_of_ratings - COUNT, album_duration - SUM).</p>
  <p>I have these annotations in queryset in ViewSet class</p>
  <pre><code>class AlbumViewSet(ModelViewSet):
      queryset = Album.objects \
          .prefetch_related(&quot;tracks&quot;, &quot;album_genres&quot;, &quot;album_genres__genre_id&quot;, &quot;album_links&quot;, &quot;reviews&quot;) \
          .select_related(&quot;aoty&quot;, &quot;artist_id&quot;) \
          .annotate(overall_score=Avg(&quot;reviews__rating&quot;, output_field=IntegerField()),
                    number_of_ratings=Count(&quot;reviews__rating&quot;, output_field=IntegerField()),
                    album_duration=Sum(&quot;tracks__duration&quot;, output_field=DurationField()))
  </code></pre>
  <p>Here are other files</p>
  <p><strong>models.py</strong></p>
  <pre><code>class Album(models.Model):
  
      RELEASE_TYPE_ALBUM_CHOICES = [
          (&quot;LP&quot;, &quot;LP&quot;),
          (&quot;EP&quot;, &quot;EP&quot;),
          (&quot;Single&quot;, &quot;Single&quot;),
          (&quot;Live&quot;, &quot;Live&quot;),
      ]
  
      title = models.CharField(max_length=255)
      slug = models.SlugField(max_length=255)
      release_date = models.DateField()
      artist_id = models.ForeignKey(
          Artist, on_delete=models.PROTECT, related_name=&quot;albums&quot;
      )
      art_cover = ResizedImageField(
          size=[750, 750], null=True, blank=True, upload_to=rename_album_art_cover)
      release_type = models.CharField(max_length=10,
                                      choices=RELEASE_TYPE_ALBUM_CHOICES, default=&quot;LP&quot;)
      created_at = models.DateTimeField(auto_now_add=True)
  
  
  class Track(models.Model):
      title = models.CharField(max_length=255)
      position = models.PositiveIntegerField()
      album_id = models.ForeignKey(
          Album, on_delete=models.PROTECT, related_name=&quot;tracks&quot;)
      duration = models.DurationField(null=True)
  
  
  class Review(models.Model):
      reviewer_id = models.ForeignKey(Reviewer, on_delete=models.PROTECT)
      rating = models.IntegerField(
          validators=[MaxValueValidator(100), MinValueValidator(0)]
      )
      review_text = models.TextField(null=True, blank=True)
      album_id = models.ForeignKey(
          Album, on_delete=models.PROTECT, related_name=&quot;reviews&quot;)
      created_at = models.DateTimeField(auto_now_add=True)
  </code></pre>
  <p><strong>serializer.py</strong></p>
  <pre><code>class AlbumSerializer(serializers.ModelSerializer):
      tracks = TrackSerializer(many=True)
      genres = StringRelatedField(
          source=&quot;album_genres&quot;, many=True)
      aoty = StringRelatedField(read_only=True)
      links = AlbumLinkSerializer(
          source=&quot;album_links&quot;, many=True, read_only=True)
      artist = SimpleArtistSerializer(source=&quot;artist_id&quot;, read_only=True)
      overall_score = serializers.IntegerField(read_only=True)
      number_of_ratings = serializers.IntegerField(read_only=True)
      album_duration = serializers.DurationField(read_only=True)
  
      class Meta:
          model = Album
          fields = [
              &quot;id&quot;,
              &quot;title&quot;,
              &quot;slug&quot;,
              &quot;created_at&quot;,
              &quot;artist&quot;,
              &quot;art_cover&quot;,
              &quot;genres&quot;,
              &quot;overall_score&quot;,
              &quot;number_of_ratings&quot;,
              &quot;release_date&quot;,
              &quot;release_type&quot;,
              &quot;tracks&quot;,
              &quot;album_duration&quot;,
              &quot;links&quot;,
              &quot;aoty&quot;
          ]
  
  class TrackSerializer(serializers.ModelSerializer):
      class Meta:
          model = Track
          fields = [&quot;position&quot;, &quot;title&quot;,  &quot;duration&quot;, &quot;album_id&quot;]
  
  class ReviewSerializer(serializers.ModelSerializer):
      reviewer = SimpleReviewerSerializer(source=&quot;reviewer_id&quot;, read_only=True)
      album = ReviewAlbumSerializer(source=&quot;album_id&quot;, read_only=True)
  
      class Meta:
          model = Review
          fields = [
              &quot;id&quot;,
              &quot;reviewer_id&quot;,
              &quot;reviewer&quot;,
              &quot;rating&quot;,
              &quot;review_text&quot;,
              &quot;album_id&quot;,
              &quot;album&quot;,
              &quot;created_at&quot;
          ]
  </code></pre>