getting history from tables

Hi,
I have two source table:

S_JOB_PAY_SCALE

JOB_TCD       TYPE_TCD  JPS_START_DT      JPS_END_DATE PAY_LEVEL_MIN PAY_LEVEL_MAX                        
158           02           2002-11-10        2005-03-21    1               4


Then i have another table S_PAY_SCALE

TYPE_TCD      START_DT        END_DT               LEVEL            WAGE_TYPE         RATE

02             2002-11-10      2003-03-31      1              1006       23.984                        
02               2003-04-01      2004-03-31      1            1006       24.704                        
02              2004-04-01      2005-03-31      1               1006       27.432

02             2002-11-10      2003-03-31      4              1006       33.984                        
02               2003-04-01      2004-03-31      4              1006       44.704                        
02              2004-04-01      2005-03-31      4               1006       57.432


Based upon TYPE_TCD,LEVEL and START_DT
and END_DT falls between JPS_START_DT      JPS_END_DATE

Final output will be:

D_JOB                                                                              
JOB_TCD           TYPE_TCD      JPS_START_DT      JPS_END_DATE  LEVEL_MIN      LEVEL_MAX WAGE_TYPE  RATE_MIN      RATE_MAX

158            02      2002-11-10      2003-03-31      1         4         1006           23.984        33.984
158            02      2003-04-01      2004-03-31      1         4         1006           24.704        44.704
158            02      2004-04-01      2005-03-21      1         4         1006           27.432        57.432

Idea is to keep history in final output based upon S_PAY_SCALE dates and also
merge the pay_rate in one line.
sam2929Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MikeOM_DBACommented:
Just Join the tables.
Show us what you got.
0
sam2929Author Commented:
Here is what i have did so far i am getting three rows  for rate_min which is ok but i need
to get rate_max too who can i do that?

SELECT
A.JOB_TCD,
A.PAY_SCALE_AREA_TCD,
A.PAY_SCALE_TYPE_TCD,
A.PAY_GROUP_MIN,
A.PAY_LEVEL_MIN,
A.PAY_GROUP_MAX,
A.PAY_LEVEL_MAX,
A.Jps_Start_Dt,
A.Jps_End_Dt ,
C.Pay_Group,
C.Pay_Level,
C.PAY_RATE
FROM HRPRSTAGEADM.S_JOB_PAY_SCALE A
inner Join S_Pay_Scale C
On A.Pay_Scale_Area_Tcd =c.Pay_Scale_Area_Tcd
And A.Pay_Scale_Type_Tcd =C.Pay_Scale_Type_Tcd
And (A.Pay_Group_Min = C.Pay_Group Or  A.Pay_Group_Max=C.Pay_Group)
And A.Pay_Level_Min = C.Pay_Level
--or  A.Pay_Level_Max = C.Pay_Level)
Where A.Job_Tcd = '10002427'
And  C.Pay_Scale_Start_Dt >= A.Jps_Start_Dt And  C.Pay_Scale_Start_Dt<= A.Jps_End_Dt
0
MikeOM_DBACommented:
Now group it like this:
  SELECT j.job_tcd, j.type_tcd, p.start_dt
       , p.end_dt, j.pay_level_min, j.pay_level_max
       , MIN ( p.lvl) level_min, MAX ( p.lvl) level_max, p.wage_type
       , MIN ( p.rate) rate_min, MAX ( p.rate) rate_max
    FROM s_job_pay_scale j, s_pay_scale p
   WHERE p.type_tcd = j.type_tcd
     AND (p.start_dt BETWEEN j.jps_start_dt AND j.jps_end_date)
     AND (p.end_dt BETWEEN j.jps_start_dt AND j.jps_end_date)
GROUP BY j.job_tcd
       , j.type_tcd
       , p.start_dt
       , p.end_dt
       , j.pay_level_min
       , j.pay_level_max
       , p.wage_type
/

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.