INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

joining two tables

joining two tables

(OP)
Hi,
Hi,
I appreciate if anyone help me out to solve my problem :
There are two table like Table 1 and Table 2:
Table 1 contain coloms like :
Emp_id
Spl_event_date ( spl training given to employee)
Name
Address
Table 2 contain :
Emp_id
Date_sal_revised
Revised_Monthly_Salary

REQUIREMENT :
Joining Table2 to Table1 on Emp_Id so that Table 1 carries one additional column SALARY like follows :

Result Table1 :

Emp_id
Spl_Event_date
Name
Address
salary

CONDITION :

Where selected SALARY from Table2 is EQUAL TO OR FIRST DATE'S GREATER THAN Spl_Event_date of table1

RE: joining two tables

Where selected SALARY from Table2 is EQUAL TO OR FIRST DATE'S GREATER THAN Spl_Event_date of table1.

Didn't get the meaning of the  above sentence. Can you repost your question more clearly?

Thanks,
Pramod

RE: joining two tables

I answered this question on Teradata Discussion Forums a few days ago.
This answer could help other users on this forum...

select T1.EMP_ID
, T1.SPL_EVENT_DATE
, T1.NAME
, T1.ADRESS
, T2.REVISED_MONTHLY_SALARY
from TABLE_1 as T1
inner join
TABLE_2 as T2
on T1.EMP_ID = T2.EMP_ID
where exists ( select 1
from TABLE_2 as T
where T2.EMP_ID = T.EMP_ID
and T1.SPL_EVENT_DATE <= T.DATE_SAL_REVISED
having T2.DATE_SAL_REVISED = min(T.DATE_SAL_REVISED)
)
;

or

select T1.EMP_ID
, T1.SPL_EVENT_DATE
, T1.NAME
, T1.ADRESS
, T2.REVISED_MONTHLY_SALARY
from TABLE_1 as T1
inner join
TABLE_2 as T2
on T1.EMP_ID = T2.EMP_ID
and T1.SPL_EVENT_DATE <= T2.DATE_SAL_REVISED
qualify T2.DATE_SAL_REVISED = min(T2.DATE_SAL_REVISED) over(partition by T2.EMP_ID)
;

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close