I'm not sure if this is possible, but....
Given this table structure:
myTable
mainID subID Amount
A1 A1 10.0
A1 A2 10.0
A1 A3 10.0
B1 B1 0.0
B1 B2 25.0
B1 B3 25.0
Is there a way to write a single UPDATE statement that
would SUM the Amount field for all like mainID records and
place it into the record where mainID = subID.
Thus the result would look like this:
myTable
mainID subID Amount
A1 A1 30.0
A1 A2 10.0
A1 A3 10.0
B1 B1 50.0
B1 B2 25.0
B1 B3 25.0
I know this can be done with incorporating views or
within a cursor...I was just trying to figure out if
it can be done in an update statement.
Thanks.
Given this table structure:
myTable
mainID subID Amount
A1 A1 10.0
A1 A2 10.0
A1 A3 10.0
B1 B1 0.0
B1 B2 25.0
B1 B3 25.0
Is there a way to write a single UPDATE statement that
would SUM the Amount field for all like mainID records and
place it into the record where mainID = subID.
Thus the result would look like this:
myTable
mainID subID Amount
A1 A1 30.0
A1 A2 10.0
A1 A3 10.0
B1 B1 50.0
B1 B2 25.0
B1 B3 25.0
I know this can be done with incorporating views or
within a cursor...I was just trying to figure out if
it can be done in an update statement.
Thanks.