Oracle函数中将参数放在模糊查询中

--diagnosis_name like '%'||diagnosis_names||'%'

create or replace function asdf(MIN_DATE IN varchar2, MAX_DATE IN varchar2,diagnosis_names varchar2) return number as--XXX诊断出院人数 不含死亡
cyzrc_by_zd number;
begin
SELECT count(*) INTO cyzrc_by_zd from pat_visit a left join diagnosis b on a.patient_id=b.patient_id and a.visit_id=b.visit_id
where diagnosis_code in (select diagnosis_code from diagnosis_dict where diagnosis_name like '%'||diagnosis_names||'%')
and a.discharge_date_time>=to_Date(MIN_DATE,'yyyy-mm-dd') and a.discharge_date_time<to_Date(MAX_DATE,'yyyy-mm-dd')+1;
return cyzrc_by_zd;
end asdf;

posted @ 2016-11-08 09:51  向阳的影子  阅读(2866)  评论(0编辑  收藏  举报