自己的写法是:
select a.sampleno,a.patientname,a.patientid,listagg(testresult,‘,‘) within GROUP (order by testresult desc) abc from bslis.l_patientinfo a,bslis.l_testresult b where a.sampleno =b.sampleno and a.examinaim=‘甲功三项‘ group by a.sampleno,a.patientid
这上面是lis的检验结果
lis中同一个样本号码对应三个testid然后是结果是分三条显示的,所以用了listagg然后就被动用了group by,所以打算lis与his信息union的话就比较难了
=======================================
select a.brid,mzhm,a.brxm,a.sfzh,xzz_qtdz,b.yz_z,b.yz_t,age,patientid from ms_brda a,ys_mz_jzls b,l_lis_sqd c,ms_yj01 d where a.brid=b.brbh and a.mzhm=c.patientid and c.doctrequestno=d.sqdh and d.jzxh=b.jzxh and (b.yz_z is not null or b.yz_t is not null) and c.examinaim like ‘甲功三项‘ and c.bed_no is null
?
这是his的病人基本信息,lis与his都有patientid,打算Union,上面提到union很难实现
?
?=============================================================================
select brid,brxm,sfzh,csny,yz_z,yz_t,patientid, max(FT3) FT3,max(FT4) FT4,max(TSH) TSH from (
select a.brid,c.age,c.patientid, f.testresult,f.testid, case when f.testid = 1111 then f.testresult else ‘‘ end FT3, case when f.testid = 1112 then f.testresult else ‘‘ end FT4, case when f.testid = 1113 then f.testresult else ‘‘ end TSH from ms_brda a,ms_yj01 d, bslis.l_jytmxx e,bslis.l_testresult f where a.brid=b.brbh and a.mzhm=c.patientid and c.doctrequestno=d.sqdh and d.jzxh=b.jzxh and (b.yz_z is not null or b.yz_t is not null) and c.examinaim like ‘甲功三项‘ and c.bed_no is null and e.sampleno = f.sampleno and c.doctrequestno = e.doctrequestno
)t group by brid,patientid
========================
上面的
select a.brid,? f.testresult,bslis.l_testresult f where a.brid=b.brbh and a.mzhm=c.patientid and? c.doctrequestno=d.sqdh and d.jzxh=b.jzxh and (b.yz_z is not null or b.yz_t is not null) and? c.examinaim like ‘甲功三项‘ and c.bed_no is null and e.sampleno = f.sampleno and c.doctrequestno = e.doctrequestno?
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|