Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Joining 2 tables

Author  Topic 

swatib
Posting Yak Master

173 Posts

Posted - 2006-01-25 : 05:01:45
I need to join 2 tables.

Table1
----------
SkillID:AgentID:TalkTime(sec)
-------------------------
1:1:1080
1:2:360
2:1:365
2:2:302

Table2
----------
SkillID:AgentID:LoginTime(sec)
-------------------------
1:1:2400
1:2:360
2:1:845
2:2:302


Expected Result
-----------------------------
SkillID:AgentID:TalkTime:LoginTime
---------------------------------
1:1:1080:2400
1:2:360:360
2:1:365:845
2:2:302:302

I tried some left upper join and other joins but every time result gives 8 records (i.e. one row from table1 to all rows from table2)

Plz help me in using proper join

Njoy Life

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-01-25 : 05:05:38
[code]select t1.SkillID, t1.AgentID, t1.TalkTime, t2.LoginTime
from Table1 t1 inner join Table2 t2
on t1.SkillID = t2.SkillID
and t1.AgentID = t2.AgentID[/code]

----------------------------------
'KH'

Happy Chinese New Year
Go to Top of Page

swatib
Posting Yak Master

173 Posts

Posted - 2006-01-25 : 05:22:04
Thanks Khtan............

Njoy Life
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-25 : 05:37:56
You need to look for joining tables in BOL, SQL Server help file

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -