加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

oracle中max使用,需求:求门诊开甲功三项的病人的基本信息与化

发布时间:2020-12-12 13:45:19 所属栏目:百科 来源:网络整理
导读:自己的写法是: 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=‘甲功三项‘ grou

自己的写法是:

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?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读