Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 I Need Sum Tree

Author  Topic 

samir.first
Starting Member

34 Posts

Posted - 2014-02-10 : 11:36:46
i have chart of Tree account is dynamic not static i don`t now nubmer of levels but i now balance of last level i need to get sum before level and before ...etc
Account Code Balance level No
11 1
1101 2
11010001 50 3
11010002 10 3
1102 2
11020001 30 3
11020002 12 3
12 1
1201 2
12011009 55 3
12011010 2 3
1202 2
12020001 66 3
12020002 92 3

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-02-11 : 00:58:00
use a recursive cte
see
http://technet.microsoft.com/en-us/library/ms186243(v=sql.105).aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -