Hi all
I am working with the following tables to create a join..and running into some problems.. the table layouts are
Table 1
------------------------------------------------
Grp Person Time Amt.Spent
------------------------------------------------
0 A 9.30 10
0 A 10.30 20
1 B 10.30 21
2 C 11.30 15
-----------------------------------------------
Table 2
------------------------------------------------
Grp Person Time Avg.Spent Amt.Left
------------------------------------------------
0 A 10.30 0 15
0 X 10.30 20 0
1 B 16.30 0 20
2 C 11.30 0 18
2 X 12.30 30 0
-----------------------------------------------
I need the final table as
------------------------------------------------
Grp Person Time Amt.Spent Amt.Left Avg.Spent
------------------------------------------------
0 A 9.30 10 - -
0 A 10.30 20 15 -
0 X 10.30 - - 20
1 B 10.30 21 - -
1 B 16.30 - 20 -
2 C 11.30 15 - 18
2 X 12.30 - - 30
-----------------------------------------------
In Brief..i need all the rows of table 1 and rows of table 2 and matching rows fitted with the required columns.
I am trying the following way but...doesnt really solve the purpose
select A.Grp, A.Person, A.Time,A.AmtSpent,B.AvgSpent,B.AmtLeft
from Table1 A
FULL OUTER JOIN
Table2 B
ON
A.Grp = B.Grp
and A.Person = B.Person
and A.Time = B.Time;
The Above Query is not working fine..ANy SUGGESTIONS..
Thanks in advance
Logic4Fun
I am working with the following tables to create a join..and running into some problems.. the table layouts are
Table 1
------------------------------------------------
Grp Person Time Amt.Spent
------------------------------------------------
0 A 9.30 10
0 A 10.30 20
1 B 10.30 21
2 C 11.30 15
-----------------------------------------------
Table 2
------------------------------------------------
Grp Person Time Avg.Spent Amt.Left
------------------------------------------------
0 A 10.30 0 15
0 X 10.30 20 0
1 B 16.30 0 20
2 C 11.30 0 18
2 X 12.30 30 0
-----------------------------------------------
I need the final table as
------------------------------------------------
Grp Person Time Amt.Spent Amt.Left Avg.Spent
------------------------------------------------
0 A 9.30 10 - -
0 A 10.30 20 15 -
0 X 10.30 - - 20
1 B 10.30 21 - -
1 B 16.30 - 20 -
2 C 11.30 15 - 18
2 X 12.30 - - 30
-----------------------------------------------
In Brief..i need all the rows of table 1 and rows of table 2 and matching rows fitted with the required columns.
I am trying the following way but...doesnt really solve the purpose
select A.Grp, A.Person, A.Time,A.AmtSpent,B.AvgSpent,B.AmtLeft
from Table1 A
FULL OUTER JOIN
Table2 B
ON
A.Grp = B.Grp
and A.Person = B.Person
and A.Time = B.Time;
The Above Query is not working fine..ANy SUGGESTIONS..
Thanks in advance
Logic4Fun