I have a table that looks like this:
col1 col2 col3 col4
a 1 n1 3
a 1 n2 4
a 2 n1 5
b 1 n1 6
b 1 n2 7
b 2 n1 8
b 2 n2 9
I would like to insert rows that will be the sum of
col4, but for the same value of col1 and col2
but different values of col3.
The rows to be inserted would look like
a 1 n1n2 7
a 2 n1n2 5
b 1 n1n2 13
b 2 n1n2 17
I have tried joing the table to itself
and using group by but I don;t know how to get the sum
I want out of it since I have to use sum(col4)
but I really want the sum of t1.col4 and t2.col4.
This is a sample problem. The real problem will have more
than two values of col3 for each col1,col2 to base the sum on. Other wise I could do it simply
using t1.col4 + t2.col4
Thanks
ds
col1 col2 col3 col4
a 1 n1 3
a 1 n2 4
a 2 n1 5
b 1 n1 6
b 1 n2 7
b 2 n1 8
b 2 n2 9
I would like to insert rows that will be the sum of
col4, but for the same value of col1 and col2
but different values of col3.
The rows to be inserted would look like
a 1 n1n2 7
a 2 n1n2 5
b 1 n1n2 13
b 2 n1n2 17
I have tried joing the table to itself
and using group by but I don;t know how to get the sum
I want out of it since I have to use sum(col4)
but I really want the sum of t1.col4 and t2.col4.
This is a sample problem. The real problem will have more
than two values of col3 for each col1,col2 to base the sum on. Other wise I could do it simply
using t1.col4 + t2.col4
Thanks
ds