Oracle:
create table zjhis.mz_zdxx_zl as select a.sfsb, wm_concat(a.zdmc) as 诊断 from zjhis.mz_zdxx a group by a.sfsb 直接可以使用
wm_concat 函数
SQl SERVER :
select t.patient_id,
t.times,
[ values ] = stuff((select ‘,’ + icd_name
from sx2017.dbo.mz_visit_diagnose
where patient_id = t.patient_id
and times = t.times
for xml path(”)), 1, 1, ”)
from sx2017.dbo.mz_visit_diagnose t
group by patient_id, times
patient_id, times 为关连字段