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)
 Need help with this query

Author  Topic 

mparter
Yak Posting Veteran

86 Posts

Posted - 2002-05-20 : 07:08:17
Here's the scenario:

I have three tables, StaffMember,StaffPost and Teams.

The StaffMember table holds staff information, related to StaffPost on National Insurance number. The StaffPost table holds all the posts that this person has in the organiztion. It may be two or three.
The StaffPost is related to the Team table using a team code.


What I want, is a query that will pull out all staff members in a certain team, but at the moment, if they have more than one post, they appear in the list twice!

I'm not sure how to set the query so it returns each individual only once in the team listing.

Thanks

dsdeming

479 Posts

Posted - 2002-05-20 : 08:02:22
Something like this should work:

SELECT DISTINCT m.StaffMember
FROM StaffMember m
JOIN StaffPost p ON m.NationalInsuranceNumber = p.NationalInsuranceNumber
JOIN Teams t ON p.Team = t.Team
WHERE t.Team = whatever

Go to Top of Page

mparter
Yak Posting Veteran

86 Posts

Posted - 2002-05-20 : 11:54:16
Figured it out myself, just wasn't thinking straight this morning!!

Thanks anyway.

Mark

Go to Top of Page
   

- Advertisement -