July 8, 2008 at 4:39 am
Hi
I have a table as follows
ID ParentID Amount
5 0
6 5 0
7 6 15
8 6 8
9 6 50
10 6 0
11 10 20
12 10 54
13 10 52
14 10 1
15 10 89
16 10 20
17 5 11
The 'ID' is the Primary key of the table. 'ParentID' is the foreign key referencing 'ID'. It shows its parent. The Instances with ID's 5, 6 and 10 are '0' because the are determined by thier 'children. That is the ammount of instance with id 10 should be the sum of instance id's 11, 12, 13, 14, 15 and 16 amounts. And Amount for id 6 is the sum of amounts of instace id's 10, 9, 8 and 7 etc.
I am wondering if anyone knows of a way i can do this
Thankyou for the help
July 8, 2008 at 4:44 am
Please don't cross post. It just wastes people's time and fragments replies.
No replies to this thread please. Direct replies to:
http://www.sqlservercentral.com/Forums/Topic529875-338-1.aspx
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply