Hello,
I have a query that I run on Oracle 9i that involves 3 tables.
Table Master
Table JHistory
Table GTNC
The primary keys in the above 3 tables are all different but there are parts of the primary key that are common to all 3 tables.
Here is my query:
select DISTINCT b.FPS_NUMBER as FPS_NUMBER,
a.SHRS_CODE,
a.ID,
a.LAST_NAME,
a.FIRST_NAME,
a.M_TYPE,
a.START_DATE,
a.END_DATE,
a.E_TYPE,
a.H_D_R_SWITCH,
a.REP_TO_NAME,
to_char(c.e_week_hours, '00') AS e_week_hours,
to_char(c.e_week_mins, '00') AS e_week_mins,
c.e_week_indicator
from MASTER a, GTNC b, JHISTORY c
WHERE a.SHRS_CODE = b.SHRS_CODE(+)
AND a.ID = b.ID(+)
and a.M_TYPE = b.M_TYPE(+)
and a.shrs_code = c.shrs_code
and a.ID = c.ID
and a.m_type = c.m_type
and c.sequence_number = 1
and a.last_name like '%ABC%'
Now, ABC exists in the master table and the GTNC table but not the JHISTORY table. XYZ exists in the master table and the JHISTORY table but not in the GTNC table. And there are multiple records for each person in the JHISTORY table and we want the record where the sequence number is 1.
So when I run the query for ABC then I get a row back but when I run the query for XYZ then I dont get anything back.
How do I join these tables?
I have a query that I run on Oracle 9i that involves 3 tables.
Table Master
Table JHistory
Table GTNC
The primary keys in the above 3 tables are all different but there are parts of the primary key that are common to all 3 tables.
Here is my query:
select DISTINCT b.FPS_NUMBER as FPS_NUMBER,
a.SHRS_CODE,
a.ID,
a.LAST_NAME,
a.FIRST_NAME,
a.M_TYPE,
a.START_DATE,
a.END_DATE,
a.E_TYPE,
a.H_D_R_SWITCH,
a.REP_TO_NAME,
to_char(c.e_week_hours, '00') AS e_week_hours,
to_char(c.e_week_mins, '00') AS e_week_mins,
c.e_week_indicator
from MASTER a, GTNC b, JHISTORY c
WHERE a.SHRS_CODE = b.SHRS_CODE(+)
AND a.ID = b.ID(+)
and a.M_TYPE = b.M_TYPE(+)
and a.shrs_code = c.shrs_code
and a.ID = c.ID
and a.m_type = c.m_type
and c.sequence_number = 1
and a.last_name like '%ABC%'
Now, ABC exists in the master table and the GTNC table but not the JHISTORY table. XYZ exists in the master table and the JHISTORY table but not in the GTNC table. And there are multiple records for each person in the JHISTORY table and we want the record where the sequence number is 1.
So when I run the query for ABC then I get a row back but when I run the query for XYZ then I dont get anything back.
How do I join these tables?