title: Django: Annotate the count of the number of duplicate values for each object
body: <p>I have a model called Product seen below. Products can have the same field 'bc_sku'.</p>
  
  <pre><code>class Product(models.Model)
  
      bc_sku                          = models.IntegerField(null=True, blank=True)
      product_type                    = models.CharField(null=True, blank=True, max_length=50)
      merchant                        = models.CharField(null=True, blank=True, max_length=50)
      product_price                   = models.DecimalField(null=True, blank=True, max_digits=10, decimal_places=2)
  </code></pre>
  
  <p>For example, imagine I had this list of objects</p>
  
  <pre><code>    bc_sku | product_type | merchant | product_price
      100    | good         | A        | 1.00
      100    | bad          | B        | 2.00
      100    | bad          | C        | 3.00
      101    | good         | A        | 7.00
      101    | bad          | B        | 5.00
  </code></pre>
  
  <p>What I'd like to do is create a query which annotates each "good" product with the count of the number of duplicates along with the minimum price for each 'bc_sku'. I would then like to be able to use these objects and values in a template.</p>
  
  <pre><code>    bc_sku | product_type | merchant | dup_count | min_price
      100    | good         | A        | 3         | 1.00
      101    | good         | A        | 2         | 5.00
  </code></pre>
  
  <p>Any help would be greatly appreciated as I'm struggling to get annotations and filters to make it work currently.</p>