Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Recursion using CTE Bottom top Approch

$
0
0
 Hi all,
        I need to evalauate 1+.5(1+.3(1+.7))etc. The .5 will be at the top most elements value, the .3 is its child's value and .7 is the childs value. When a new value .8 comes beneath .7 it should be 1+.5(1+.3(1+.7(1+.8))). So the simplest way is recursion.

      But while using Recursion in SQL i'm getting (1+.5)*(1+.3)*(1+.7)*(1+.8). How can i achive the right result?
     
      It seems like CTE is looping only and not doing recursion. Am i right?


Thanking you,
Binesh Nambiar C

Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>