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
 Transact-SQL (2000)
 SQL Select

Author  Topic 

diggers
Starting Member

8 Posts

Posted - 2005-02-17 : 15:28:49
Hello,

I need to extract data from my DB and filter it on 3 elements. The Db is a hospital DB with patients etc. I have the following select statement:

SELECT LASTNAME, NAME
FROM ADMISSIONS ADMISSIONS, EVENTDATA EVENTDATA, EVENTS EVENTS, PATIENTS PATIENTS, PICISDATA PICISDATA
WHERE PATIENTS.PATIENTDBOID = ADMISSIONS.PATIENTDBOID AND
PICISDATA.ADMISSIONDBOID = ADMISSIONS.ADMISSIONDBOID AND
EVENTDATA.EVENTDBOID = EVENTS.EVENTDBOID AND EVENTDATA.PICISDATADBOID = PICISDATA.PICISDATADBOID AND
EVENTDATA.EVENTDBOID NOT IN (66188362240347002999,66000000000049000000,66188362240347002999)

This returns too many rows for me. What I would like is to return the name of each patient who does not have the 3 eventdboids in their record. What this returns is the name of the Patients and lists the dboids. Any ideas? Is there a better way to filter out infomation


TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-02-17 : 16:06:10
I guess you need all those tables to get from Patients to EventData, huh?. If that's the case, try slapping
Group by LastName, Name

at the end of your statement.

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -