sql server - Need to have LIKE and specific code in one sql -
in following, getting patients have visited department 2 , have diagnosis_code in starting 'e11.' .
i group of patients have specific code 'i10'.
how can code here both groups. create column each. e11. 'diab'. i10 'hyper', in addition other columns showing. patient can have had both of these btw.
select vouchers.billing_date, vouchers.voucher_id, vwgenpatapptinfo.appt_status, vwgenpatapptinfo.appt_sched_department_id, vwgenpatinfo.patient_first_name, vwgenpatinfo.patient_last_name, vouchers.patient_id, diagnosis_codes.diagnosis_code ((ntier_70751.pm.service_diagnoses service_diagnoses inner join ntier_70751.pm.services services on service_diagnoses.service_id=services.service_id) inner join ntier_70751.pm.diagnosis_codes diagnosis_codes on service_diagnoses.diagnosis_code_id=diagnosis_codes.diagnosis_code_id) inner join ((ntier_70751.pm.vwgenpatapptinfo vwgenpatapptinfo inner join ntier_70751.pm.vouchers vouchers on vwgenpatapptinfo.patient_id=vouchers.patient_id) inner join ntier_70751.pm.vwgenpatinfo vwgenpatinfo on vwgenpatapptinfo.patient_id=vwgenpatinfo.patient_id) on services.voucher_id=vouchers.voucher_id vwgenpatapptinfo.appt_sched_department_id=2 , vwgenpatapptinfo.appt_status='a' , vouchers.billing_date>=n'01-01-2016' , diagnosis_codes.diagnosis_code 'e11.%' order vouchers.patient_id
try replacing
"diagnosis_codes"."diagnosis_code" 'e11.%'
with
("diagnosis_codes"."diagnosis_code" 'e11.%' or "diagnosis_codes"."diagnosis_code" 'i10.%')
and see if gives result want :)
Comments
Post a Comment