BMS-HOSxP Community
HOSxP => Report Exchange => ข้อความที่เริ่มโดย: golf_pk ที่ กรกฎาคม 04, 2014, 18:38:19 PM
-
select count(distinct(hn)) as hn from ovstdiag o
where o.vstdate BETWEEN "2010-10-01" AND "2011-09-30" and icd10 BETWEEN "A070" and "A099"
union
select count(distinct(ip.hn)) as hn from iptdiag i,ipt ip
where i.an=ip.an and ip.dchdate BETWEEN "2010-10-01" AND "2011-09-30" and icd10 BETWEEN "A070" and "A099"
มันจะได้ผู้จำนวนผู้ป่วยออกมา 2 บรรทัด แต่อยากให้ทั้งสองบวกกันทำไงดีครับ.......
-
ดันครับ ...
-
ขออธิบายเพิ่มเติมครับ นี้คือโจทย์ หาจำนวนผู้ป่วยที่เป็นโรค อุจจาระร่วง ครับ
พอเอามา union แล้ว แต่กลับทำให้เป็นตัวเลขรวมใน 1 บรรทัดไม่ได้ครับ
มือใหม่หัดเขียนครับ
??? ??? ??? ??? ???
-
ใช้เป็น variable กำหนดตัวแปรมารับค่า แล้วค่อยเอามาบวกกัน ไม่รู้ว่าจะชอบวิธีการนี้หรือป่าวครับ แต่ผมว่าง่ายดีนะ
-
;D แบบนี้ไหมครับ
select count(distinct(hn)) as hn from ovstdiag o
where o.vstdate BETWEEN "2010-10-01" AND "2011-09-30" and icd10 BETWEEN "A070" and "A099";
+
select count(distinct(ip.hn)) as hn from iptdiag i,ipt ip
where i.an=ip.an and ip.dchdate BETWEEN "2010-10-01" AND "2011-09-30" and icd10 BETWEEN "A070" and "A099" ;
-
ผมไปเจอรูปแบบนี้มา
select tem.name, count(*)
from(select name from results
union all
select name from archive_results) as tem
group by name
order by name
แต่จะปรับเข้ากับโค้ดนี้อย่างไร
select count(distinct(hn)) as hn from ovstdiag o
where o.vstdate BETWEEN "2010-10-01" AND "2011-09-30" and icd10 BETWEEN "A070" and "A099"
union
select count(distinct(ip.hn)) as hn from iptdiag i,ipt ip
where i.an=ip.an and ip.dchdate BETWEEN "2010-10-01" AND "2011-09-30" and icd10 BETWEEN "A070" and "A099"
-
;D แบบนี้ไหมครับ
select count(distinct(hn)) as hn from ovstdiag o
where o.vstdate BETWEEN "2010-10-01" AND "2011-09-30" and icd10 BETWEEN "A070" and "A099";
+
select count(distinct(ip.hn)) as hn from iptdiag i,ipt ip
where i.an=ip.an and ip.dchdate BETWEEN "2010-10-01" AND "2011-09-30" and icd10 BETWEEN "A070" and "A099" ;
ผมลองรันในสายฟ้าแล้ว Error ครับ
-
พอดีได้โจทย์นี้มาครับ
-
;D แบบนี้ไหมครับ
select count(distinct(hn)) as hn from ovstdiag o
where o.vstdate BETWEEN "2010-10-01" AND "2011-09-30" and icd10 BETWEEN "A070" and "A099";
+
select count(distinct(ip.hn)) as hn from iptdiag i,ipt ip
where i.an=ip.an and ip.dchdate BETWEEN "2010-10-01" AND "2011-09-30" and icd10 BETWEEN "A070" and "A099" ;
ผมลองรันในสายฟ้าแล้ว Error ครับ
ลอง Run Navicat ดูนะครับ ผม Run ได้ปกตินะ
-
;D แบบนี้ไหมครับ
select count(distinct(hn)) as hn from ovstdiag o
where o.vstdate BETWEEN "2010-10-01" AND "2011-09-30" and icd10 BETWEEN "A070" and "A099";
+
select count(distinct(ip.hn)) as hn from iptdiag i,ipt ip
where i.an=ip.an and ip.dchdate BETWEEN "2010-10-01" AND "2011-09-30" and icd10 BETWEEN "A070" and "A099" ;
;D ;D ;D ;D ได้แล้วครับ
ขอบคุณมากครับ
select ( select count(distinct(hn)) as hn from ovstdiag o
where o.vstdate BETWEEN "2010-10-01" AND "2011-09-30" and icd10 BETWEEN "A070" and "A099" )
+ ( select count(distinct(ip.hn)) as hn from iptdiag i,ipt ip
where i.an=ip.an and ip.dchdate BETWEEN "2010-10-01" AND "2011-09-30" and icd10 BETWEEN "A070" and "A099" )
as total_rows
-
ขอบคุณ อ.terminator2014
และอ.golf_win มาก ๆ ครับ
ผมได้ไปต่อละ ขอบคุณคร๊าฟฟ