title: SQL SERVER - sum over partition by distinct
body: <pre><code> rN         rD          rnc      d     expectedResult
  abc1m      2010-03-31   abc     5.7    5.7 + 1.7 +9.6
  abc3m      2010-03-31   abc     5.7    5.7 + 1.7 +9.6
  abc1y      2010-03-31   abc     5.7    5.7 + 1.7 +9.6
  xfx1m      2010-03-31   xfx     1.7    5.7 + 1.7 +9.6
  xfx3m      2010-03-31   xfx     1.7    5.7 + 1.7 +9.6
  xfx1y      2010-03-31   xfx     1.7    5.7 + 1.7 +9.6
  tnt1m      2010-03-31   tnt     9.6    5.7 + 1.7 +9.6
  tnt3m      2010-03-31   tnt     9.6    5.7 + 1.7 +9.6
  tnt1y      2010-03-31   tnt     9.6    5.7 + 1.7 +9.6
  ------------------------------------
  abc1m      2010-04-01   abc     2.2    2.2 + 8.9 + 5.5
  abc3m      2010-04-01   abc     2.2    2.2 + 8.9 + 5.5
  abc1y      2010-04-01   abc     2.2    2.2 + 8.9 + 5.5
  xfx1m      2010-04-01   xfx     8.9    2.2 + 8.9 + 5.5
  xfx3m      2010-04-01   xfx     8.9    2.2 + 8.9 + 5.5
  xfx1y      2010-04-01   xfx     8.9    2.2 + 8.9 + 5.5
  tnt1m      2010-04-01   tnt     5.5    2.2 + 8.9 + 5.5
  tnt3m      2010-04-01   tnt     5.5    2.2 + 8.9 + 5.5
  tnt1y      2010-04-01   tnt     5.5    2.2 + 8.9 + 5.5
  </code></pre>
  
  <p><strong>expected result</strong> is the sum of distinct rnc for a specific date 
  How to achieve this.
  I would like to use something like the code below but doesn't work. </p>
  
  <pre><code>select *,
  sum (d) over (partition by rD, distinct rnc) as expectedResult
  from myTable
  where ...--some condition
  order by ...--order by some columns
  </code></pre>
  
  <p>Using SQL Server 2012, thanks </p>
  
  <p><strong>edit:</strong> Regarding the question being on hold, how is this unclear. IF one is only looking at the column <code>expectedResult</code> isn't it quite clear? What should I add in order to make it better?
  --And every rnc has d. Just assume every set is of the form given in the example. (answering one comment)</p>