Daniel Lane
asked on
MS SQL Server - Looking to filter rows based on column value
Hi Experts,
I am using the following script to pull some data.
Is there any way to remove from the result set any rows where pp.service_item_id is either null or is not in the following list of codes, something along the lines of
Using that clause above just filters them from the results, but they still exist. I'm looking for where they don't exist.
Hopefully that makes sense, If more detail is needed I can provide.
Thanks!
I am using the following script to pull some data.
select
pe.enc_timestamp,
pe.enc_nbr,
cf.ecg_diag_code,
pp.service_item_id,
pp.service_item_desc
from VCS_CARD_Finalize_ cf
join CARD_Finalize_ cff with (nolock) on cf.enc_id = cff.enc_id
left join patient_procedure pp with (nolock) on cf.enc_id = pp.enc_id
join patient_encounter pe with (nolock) on cf.enc_id = pe.enc_id
where cf.ecg_cb = 1
and cff.SignedName !=''
--and pp.service_item_id not in ('93000','9300059','93000 GW','93000 51','93000 59','93000','93000 59GW','93010 59','93010 GW')
--and pp.service_item_id is null
order by enc_timestamp desc, enc_nbr desc
Is there any way to remove from the result set any rows where pp.service_item_id is either null or is not in the following list of codes, something along the lines of
pp.service_item_id not in ('93000','9300059','93000 GW','93000 51','93000 59','93000','93000 59GW','93010 59','93010 GW')
Using that clause above just filters them from the results, but they still exist. I'm looking for where they don't exist.
Hopefully that makes sense, If more detail is needed I can provide.
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Exactly what i was looking for Scott, You are the man. Thanks!
Please try this simple -
Open in new window
Hope it helps!