NinjaTurtle
01-30-2007, 08:37 AM
Hi,
I have two tables:
table A
Id. | id_result | value
1 | 1| 10
2 | 1| 11
3 | 2| 7
4 | 2| 13
table B
Id. | id_result | value
1 | 1| 4
2 | 1| 1
3 | 2| 5
4 | 2| 6
How can I get sum of unique keys from table A and B (id_result) like this?:
id_result | sum_table_A | sum_table_B
1 | 21| 5
2 | 20| 11
I can do it with UNION or 2 separate SQL statement, but how to make it in 1 query or using subquery?
Jason
I have two tables:
table A
Id. | id_result | value
1 | 1| 10
2 | 1| 11
3 | 2| 7
4 | 2| 13
table B
Id. | id_result | value
1 | 1| 4
2 | 1| 1
3 | 2| 5
4 | 2| 6
How can I get sum of unique keys from table A and B (id_result) like this?:
id_result | sum_table_A | sum_table_B
1 | 21| 5
2 | 20| 11
I can do it with UNION or 2 separate SQL statement, but how to make it in 1 query or using subquery?
Jason