title: Get total count per ID change
body: <p>how can I get a total count of sheets per change of sheet</p>
  
  <p>example:</p>
  
  <pre><code>select sheetID,
         ..
  from SomeTable
  </code></pre>
  
  <p>results look something like this:</p>
  
  <pre><code>sheetID
  -----------
  1000
  1000
  1000
  1000
  3000
  3000
  3000
  </code></pre>
  
  <p>so I want something like this:</p>
  
  <pre><code>select sheetID,
         count(sheetID) as TotalsheetCount
  from SomeTable
  </code></pre>
  
  <p>I just don't know how to break the count up per change of sheetID.</p>
  
  <p>So I'd end up with this essentially:</p>
  
  <pre><code>sheetID   TotalsheetCount
  --------  -----------
  1000          4
  1000          4
  1000          4
  1000          4
  3000          3
  3000          3
  3000          3
  </code></pre>
  
  <p>so 4 is because there are 4 1000s, 3 because there are 3 3000s.  I am wanting to repeat the total count for that sheetID for each row, even though it's repeating, I want to provide that.</p>
  
  <p>UPDATE, here's what I did per the replies but I'm getting way too many results now as compoared to the count where I did not add that partition count before</p>
  
  <pre><code>   select MainTable.sheetID,
             COUNT(SomeTable.sheetID)OVER(PARTITION BY SomeTable.sheetID) AS TotalSheetCount
             table2.SomeField1,
             table2.SomeField1
      from MainTable
          join (select distinct Sales.SalesKey from SomeLongTableName_Sales) sales on sales.SheetKey = MainTable.sheetKey
          left outer join Site on MainTable.SiteKey = Site.SiteKey
          join Calendar on sales.Date &gt;= Calendar.StartDate
               and sales.Date &lt; Calendar.EndDate
          group by SomeTable.sheetID
  </code></pre>
  
  <p>the joins and stuff is more realistic to my real query but formatted for this post to hide real field and table names.</p>