title: SUM OVER PARTITION BY
body: <p>What am I missing?</p>
  
  <p>This query is returning duplicate data over and over again.  The count is correct for a complete total, but I am expecting one row, and yet I am getting the value repeated about 40 times.  Any ideas?</p>
  
  <pre><code>SELECT BrandId
        ,SUM(ICount) OVER (PARTITION BY BrandId ) 
    FROM Table 
  WHERE DateId  = 20130618
  </code></pre>
  
  <p>I get this?</p>
  
  <pre><code>BrandId ICount
  2       421762
  2       421762
  2       421762
  2       421762
  2       421762
  2       421762
  2       421762
  1       133346
  1       133346
  1       133346
  1       133346
  1       133346
  1       133346
  1       133346
  </code></pre>
  
  <p>What am I missing?</p>
  
  <p>I cant remove the partition by as the entire query is like this:</p>
  
  <pre><code>SELECT BrandId
         ,SUM(ICount) OVER (PARTITION BY BrandId) 
         ,TotalICount= SUM(ICount) OVER ()    
          ,SUM(ICount) OVER () / SUM(ICount) OVER (PARTITION BY BrandId)  as Percentage
  FROM Table 
  WHERE DateId  = 20130618
  </code></pre>
  
  <p>Which returns this:</p>
  
  <pre><code>BrandId (No column name)    TotalICount Percentage
  2       421762              32239892    76
  2       421762              32239892    76
  2       421762              32239892    76
  2       421762              32239892    76
  2       421762              32239892    76
  2       421762              32239892    76
  </code></pre>
  
  <p>I would expect output something like this without having to use a distinct:</p>
  
  <pre><code>BrandId (No column name)    TotalICount Percentage
  2       421762              32239892    76
  9       1238442             32239892    26
  10      1467473             32239892    21
  </code></pre>