I have two tables
table1
---------
empno varchar2(5)
year varchar2(4)
field1 number(2)
field2 number(2)
table2
----------
empno varchar2(5)
year varchar2(4)
field3 number(2)
field4 number(4)
The primary key in both tables is (empno,year)
I have the following stats:
select count(*) from table1 where year='2013';
result: 195
select count(*) from table2 where year='2013';
result: 555
the inner join produces:
select count(*) from table1,table2 where table1.empno=table2.empno
and table1.year='2013' and table2.year='2013;
result: 40
so if I am to do an outer join between table1 and table2 on empno and year='2013'
I should get : 195+555-40=710
but when I run the following commands:
select count(*) from table1 full join table2 on table1.empno=table2.empno and
table1.year='2013' and table2.year='2013;
result:3584
select count(*) from table1 full join table2 on table1.empno=table2.empno where
table1.year='2013' and table2.year='2013;
result:40
both not producing the correct result.
What is the correct syntax for the outer join command given the table structure above? and,
what would be the correct syntax if there was a third table with the following structure
table 3
----------
empno varchar2(5)
year varchar(4)
field5 number(2)
field6 number(2)
again the primary key is (empno,year)
Thank you.