BMS-HOSxP Community
HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: Man Of Romance ที่ มิถุนายน 10, 2012, 13:34:02 PM
-
น้องกายภาพคนงาม เขาขอรายงานว่า
1. จากวันที่.......... ถึงวันที่................คลินิก กายภาพ มีผู้ใช้บริการกี่คน
2. แยกตาม Diag ว่า Diag นี้ กี่ครั้ง/ กี่คน
3. แยกตามสิทธิ์ ว่า สิทธิ์ว่า สิทธิ์นี้ กี่ครั้ง/กี่คน ครับ
ช่วยสงเคราะคำสั่ง หรือรายงาน (ถ้ามี) ให้ด้วยครับ (ผมทำแล้วมันไม่ได้)
ขอบคุณอย่างสูง
-
select count(distinct hn) เอาครับถ้านับคน
select count(vn) ถ้านับครั้ง
================================================
-
ประมาณนี้ไหมครับ
select pt.name As pttype_name,count(distinct (v.hn)) As cc from vn_stat v
left outer join ovst o on(v.vn=o.vn)
left outer join pttype pt on(v.pttype=pt.pttype)
where v.vstdate between "2011-05-01" and "2012-05-31"
and o.main_dep="002"
group by v.pttype
select pt.name As pttype_name,count(distinct (v.vn)) As cc from vn_stat v
left outer join ovst o on(v.vn=o.vn)
left outer join pttype pt on(v.pttype=pt.pttype)
where v.vstdate between "2011-05-01" and "2012-05-31"
and o.main_dep="002"
group by v.pttype
select i.name As pdx_name,count(distinct (v.hn)) As cc from vn_stat v
left outer join ovst o on(v.vn=o.vn)
left outer join icd101 i on(v.pdx=i.code)
where v.vstdate between "2011-05-01" and "2012-05-31"
and o.main_dep="002"
group by v.pdx
select i.name As pdx_name,count(distinct (v.vn)) As cc from vn_stat v
left outer join ovst o on(v.vn=o.vn)
left outer join icd101 i on(v.pdx=i.code)
where v.vstdate between "2011-05-01" and "2012-05-31"
and o.main_dep="002"
group by v.pdx