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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-12-07 : 08:06:30
|
| David writes "I have a quick problem that would be nice to get a bit of help with.I want to join empolyees on employee bank accounts but only want the first record for each employee even though it is a 1-M relationship.i.e., starting with:EMP_ID(PK), NAMEACCT_ID(PK), EMP_ID resulting in:EmpID(PK), Name, Acct_ID (just the first acct_id, no matter how many there are)It is a trival enough sounding query but SQL doesn't like to throw away perfectly good data." |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
druer
Constraint Violating Yak Guru
314 Posts |
Posted - 2005-12-07 : 09:26:33
|
| select emp.name, emp.address, act.idfrom employee emp, (select top 1 id from accounts where accounts.emp_id = emp.emp_id) act |
 |
|
|
|
|
|