bakerboy_1111
Registered User.
- Local time
- Today, 09:02
- Joined
- Dec 1, 2003
- Messages
- 43
Hello all,
I have a table at the moment that has the following columns:
Parent_Tag, Child_Tag, Value and Level.
This table represents a tree diagram. The Parent_Tag is the name of the level connected directly above the Child_Tag.
The Child_Tag has an associated Value and Level. The Value is just a number that will be summed, and the Level represents how far down the tree diagram the current Child_Tag is. That is, 0 for top level, 1 for next level etc.
This table has been generated using an append query. Basically, a Child_Tag will have a value only if it is not a Parent_Tag for any other Child_Tag (i.e. if it is at the end of a tree branch). All other Value entries will be Null.
For all these Null values, I would like to add up the Values connected below.
My idea is that I should be able to make an update query that does the following:
- checks to see if a Child_Tag has a Null Value
- Sum the Values for the cases where these Child_Tags are Parent_Tags
- store the summed Value back in the table to replace the Null
As far as I can tell, this will have to be a loop, because the lowest levels will have to be summed before the top ones.
Does anyone know how to design this? Any help will be greatly appreciated.
Cheers,
Bakerboy
PS: I've attached a sample database table to help explain.
I have a table at the moment that has the following columns:
Parent_Tag, Child_Tag, Value and Level.
This table represents a tree diagram. The Parent_Tag is the name of the level connected directly above the Child_Tag.
The Child_Tag has an associated Value and Level. The Value is just a number that will be summed, and the Level represents how far down the tree diagram the current Child_Tag is. That is, 0 for top level, 1 for next level etc.
This table has been generated using an append query. Basically, a Child_Tag will have a value only if it is not a Parent_Tag for any other Child_Tag (i.e. if it is at the end of a tree branch). All other Value entries will be Null.
For all these Null values, I would like to add up the Values connected below.
My idea is that I should be able to make an update query that does the following:
- checks to see if a Child_Tag has a Null Value
- Sum the Values for the cases where these Child_Tags are Parent_Tags
- store the summed Value back in the table to replace the Null
As far as I can tell, this will have to be a loop, because the lowest levels will have to be summed before the top ones.
Does anyone know how to design this? Any help will be greatly appreciated.
Cheers,
Bakerboy
PS: I've attached a sample database table to help explain.
Attachments
Last edited: