470,596 Members | 1,396 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,596 developers. It's quick & easy.

SQL Hierarchy and Sum on Same Table

Hi,

I am new to T-SQL, I am trying to fill-in a table with data already present in the table. The data to be used is located in type = C
The problem is that the value in Type = B is the the sum of the Values of Type C but ONLY from the following rows AND until another type is encountered.
(for exemple value in id = 2 is only 100 + 105 and in id = 5 it is only 79)
Same principal applies for Type A but with the B values.
The table looks like this:

id type value
1 A NULL
2 B NULL
3 C 100
4 C 105
5 B NULL
6 C 79
7 B NULL
8 C 46
9 C 23
10 C 26
11 A NULL
12 B NULL
13 C 126
14 C 138
15 B NULL
16 C 149

Can someone get me started with a code?
I am stuck...

Thank you for your help,
Jun 29 '07 #1
0 1012

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Troy Lynch | last post: by
1 post views Thread by Chris Lasher | last post: by
2 posts views Thread by Darryll Petrancuri | last post: by
822 posts views Thread by Turamnvia Suouriviaskimatta | last post: by
2 posts views Thread by Yaro | last post: by
reply views Thread by Ed West | last post: by
2 posts views Thread by Do | last post: by
1 post views Thread by dasein fiasco | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.