title: How to find Running Multiplication
body: <p>Not sure is this the right title. I need to find the <code>cumulative multiplication</code> as like running total. </p>
  
  <p>Searched the forum and got a excellent <a href="https://stackoverflow.com/questions/5416169/mutiplication-aggregate-operator-in-sql"><em>answer</em></a>. But it is not the exact answer for me.</p>
  
  <p>so modified the answer to my requirement.</p>
  
  <pre><code>SELECT *,
         (SELECT CASE
                   WHEN Min(Abs(Column1)) = 0 THEN 0
                   ELSE Exp(Sum(Log(Abs(NULLIF(Column1, 0))))) -- the base mathematics
                        * Round(0.5 - Count(NULLIF(Sign(Sign(Column1) + 0.5), 1))%2, 0) -- pairs up negatives
                 END
          FROM   TEMP a
          WHERE  B.ID &gt;= A.ID) as  Running_Mul
  FROM   TEMP B 
  </code></pre>
  
  <p>And I got my answer. Now Is there any better way of doing this in <code>Sql Server 2008</code>?</p>
  
  <p><strong>Sample data:</strong></p>
  
  <pre><code>ID  Column1 
  --  -------
  1   1       
  2   2       
  3   4       
  4   8       
  5   -2  
  </code></pre>
  
  <p><strong>Expected Result:</strong>    </p>
  
  <pre><code>ID  Column1 Running_Mul
  --  ------- -----------
  1   1       1
  2   2       2
  3   4       8
  4   8       64
  5   -2      -128
  </code></pre>
  
  <p><a href="http://sqlfiddle.com/#!3/997fe/2" rel="nofollow noreferrer"><strong>Sql Fiddle</strong></a></p>