BMS-HOSxP Community

HOSxP => Report Exchange => ข้อความที่เริ่มโดย: panus_t ที่ ตุลาคม 23, 2016, 10:58:44 AM

หัวข้อ: ขอคำสั่งดึง 10 อันดับหัตถการ OPD และ IPD หน่อยครับ
เริ่มหัวข้อโดย: panus_t ที่ ตุลาคม 23, 2016, 10:58:44 AM
ขอคำสั่งดึง 10 อันดับหัตถการ OPD และ IPD หน่อยครับ  ;D
หัวข้อ: Re: ขอคำสั่งดึง 10 อันดับหัตถการ OPD และ IPD หน่อยครับ
เริ่มหัวข้อโดย: tumtouch28 ที่ กุมภาพันธ์ 18, 2017, 10:44:39 AM
สำหรับ 10 อันดับของหัตถการ OPD จะใช้คำสั่งประมาณนี้คับ

select er.name ,  count(d.er_oper_code)
from doctor_operation  d
left join er_oper_code er on er.er_oper_code = d.er_oper_code
where date(d.begin_date_time) between  "2016-10-01" and "2016-10-31"
group by d.er_oper_code
order by count(d.er_oper_code)  desc
limit 10

และสำหรับ 10 อันดับของหัตถการ IPD จะใช้คำสั่งประมาณนี้คับ

select er.name ,  count(i.ipt_oper_code)
from ipt_nurse_oper i
left join ipt_oper_code er on er.ipt_oper_code = i.ipt_oper_code
where date(i.begin_date_time) between  "2016-10-01" and "2016-10-31"
group by i.ipt_oper_code
order by count(i.ipt_oper_code)  desc
limit 10