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.
Author |
Topic |
cognos79
Posting Yak Master
241 Posts |
Posted - 2007-05-11 : 12:25:40
|
I have two tables:table 1--------------------------------empid12table 2---------------------------------empid deptid1 201 212 302 313 40when i join the two tables on empid i want to retrieve only one record for each empid. It doesnt matter which deptid is pulled.end result should look like this.result:1 20(or 21)2 30(or 31).any help |
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-05-11 : 12:29:51
|
[code]SELECT empid, min(deptid) FROM Table1 T1JOIN Table2 T2 ON T1.Empid = T2.EmpIdGROUP BY T1.EmpId[/code]Dinakar NethiSQL Server MVP************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
cognos79
Posting Yak Master
241 Posts |
Posted - 2007-05-11 : 13:23:49
|
Thanks dinakar |
 |
|
|
|
|