>I have 2 tables as shown here.
>
>Table1
>Cell Widgets
>A 2
>B 1
>E 2
>D 1
>
>
>Table2
>Cell Widgets
>A 1
>C 2
>D 1
>C 1
>
>I need get the distinct cells and a count of the number of widgets from each table. The result should be as follows.
>
>Result.
>Cell Widgets
>A 3
>B 1
>C 3
>D 2
>E 2
>
>Ideally, I would like to use more than 10 tables at once for this operation. There are other columns like widgets that I would like to sum up obviously, but I hope from this example I will be able to proceed further.
>
>TIA.
>
>Ramone.
It could be done in two selects:
select nvl(A1.Cell, B1.Cell) as Cell, nvl(A1.Cnt1,0) as Cnt1, nvl(B1.Cnt1,0) as Cnt2 from Table1 A1 outer join Table2 B1 on A1.Cell=B1.Cell into cursor curSum
select Cell, Cnt1+Cnt2 as Cnt from curSum into cursor curResult
If it's not broken, fix it until it is.
My Blog