Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi All,I would have thought this is an easy proc to write but I am having major hassles here.What I have is a linking table which has the following data.StaffID ¦ ClinicIDWhat I am trying to do is find out all the Distinct ClinicID which don't have a matching StaffID.So if the database goes something like this.StaffID ¦ ClinicID 2 1 2 3 3 1 4 2So now I I run the query with staffID of 2 I want it to return '2' since that is the only clinicID that it doesn't match with. The problem I keep on getting is that it is returning '1' and '2' because '1' is also linked with staffID '3'.I hope I made sense with that.Please could someone tell me what I am doing wrong. I have the following.SELECT DISTINCT(pc_ClinicID), pc_ClinicName FROM sbt_ParticipatingClinics INNER JOIN ssbt_ClinicUsers ON sbt_ParticipatingClinics.pc_ClinicID = ssbt_ClinicUsers.cu_ClinicIDWHERE ssbt_ClinicUsers.cu_ClinicStaffID != @StaffID Order By pc_ClinicID?????