Jeremy McDevitt
Jeremy McDevitt

Reputation: 115

Excluding certain results for SQL Query

Wasn't quite sure how to do this, but I'm sure it is pretty simple. For p.program_id I get several results such as OP, TEST, SA, INTAKE, etc and I would like to exclude intake, court, and test from those results. I would also like to do the same for patient_id to exclude our test users which I'm assuming would be the same thing. Figure it is some sort of exclude command to put in the where statement. I just don't know it. Thanks.

select 
    distinct p.patient_id,
    p.date_discharged,
    p.discharge_reason,
    pa.lname+', '+pa.fname as 'Patient',
    p.clinic_id,
    p.service_id,
    p.program_id,
    p.protocol_id
from patient_assignment p
join patient pa
    on p.patient_id = pa.patient_id
where (p.date_discharged between '2013-01-01 00:00:00.000'
                             and '2013-06-01 00:00:00.000')

Upvotes: 0

Views: 265

Answers (1)

agad
agad

Reputation: 2189

where p.program_id not in ('OP', 'TEST', 'SA', 'INTAKE' )

Upvotes: 2

Related Questions