แสดงกระทู้

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - woravet

หน้า: 1 [2] 3 4 ... 9
51
ลองทดสอบยาคับ
พอรายการที่ 2 จะขึ้น Error เลย
ตรวจสอบเครื่องหมาย ' และ " แล้ว
ทั้งใน drugitems,nondrugitems,s_drugitems

52
ใส่รายการยาที่ใช้ประจำ ของผู้ป่วย DM
ในรายการที่ 2  แล้ว Error
ตรวจสอบ หรือแก้ไขอย่างไรครับ

53
select v.pttype,count(v.vn) as vn,count(distinct v.hn) as hn,sum(v.income) as income,p.name
from (select vn from dtmain
where vstdate between "2014-01-01" and "2014-05-31"
and vsttime > "16:00:00"
group by vn) d
left join vn_stat v on d.vn=v.vn
left join pttype p on v.pttype=p.pttype
group by v.pttype

54
ลองตรวจสอบ a,b ได้เป็น integer มั๊ย
สงสัยได้เป็น null
*****
ตรวจสอบดูนะคับ
*****
email/FB:woravet12@hotmail.com

57
select o.vstdate,count(o.vn) 'Total',sum(c.complete='Y') 'Complete'
,count(o.vn)-sum(c.complete='Y') 'CC'
,sum(o.an is not null) 'Admit'
from ovst o
left join vn_opd_complete c on o.vn=c.vn
where o.vstdate between '2014-1-1' and '2014-1-31'
group by o.vstdate

58
กำหนด format cell เป็นอะไรรึป่าว

59
การเขียน SQL Script / Re: ขอคำแนะนำหน่อยครับ SQL
« เมื่อ: เมษายน 03, 2014, 15:49:55 PM »
select v.*
from (select max(vn) vn
from vn_stat
where vstdate between "2014-01-01" and "2014-03-31"
and pdx="I10"
group by hn
order by hn) as a
left join vn_stat v on a.vn=v.vn
*****
เป้นที่ version ของ mysql
ผมติด..ไม่ค่อยใส่ as

60
การเขียน SQL Script / Re: ขอคำแนะนำหน่อยครับ SQL
« เมื่อ: เมษายน 03, 2014, 13:53:37 PM »
select v.*
from (select max(vn) vn
from vn_stat
where vstdate between "2014-01-01" and "2014-03-31"
and pdx="I10"
group by hn
order by hn) a
left join vn_stat v on a.vn=v.vn

61
set @chw:=(select chwpart from hospcode where hospcode=(select hospitalcode from opdconfig));
select if(a.hospmain='99999','µèÒ§¨Ñ§ËÇÑ´',a.name) name,sum(a.rw<0.5) cc
from (select if(h.chwpart=@chw,o.hospmain,'99999') hospmain,h.name
,i.rw,i.dchdate
from ipt i
left join ovst o on o.vn=i.vn
left join hospcode h on h.hospcode=o.hospmain
left join pttype p on o.pttype=p.pttype
left join ipt_labour lr on lr.an=i.an
left join ipt_newborn nb on nb.an=i.an
where i.dchdate between '2012-10-1' and '2013-9-30'
and lr.an is null
and nb.an is null
and p.pttype_spp_id in (3,4)) a
group by hospmain

62
set @ds1:='2012-10-1';
set @ds2:='2013-9-30';
select a.women_birth_control_id id,a.women_birth_control_name name
,ifnull(b.cc,0) Total
,ifnull(b.incase,0) incase
,ifnull(b.invisit,0) invisit
,ifnull(b.outcase,0) outcase
,ifnull(b.outvisit,0) outvisit
from women_birth_control a
left join (select s.women_birth_control_id,count(*) cc
,count(distinct if(v.village_moo<>0,p.cid,null)) incase
,count(if(v.village_moo<>0,p.cid,null)) invisit
,count(distinct if(v.village_moo=0,p.cid,null)) outcase
,count(if(v.village_moo=0,p.cid,null)) outvisit
from person_women_service s
left join person_women w on w.person_women_id=s.person_women_id
left join person p on p.person_id=w.person_id
left join village v on p.village_id=v.village_id
where s.service_date between @ds1 and @ds2
and s.women_service_id=1
group by s.women_birth_control_id) b on a.women_birth_control_id=b.women_birth_control_id
where a.women_birth_control_id>0
order by 1

63
set @ds1:='2012-10-1';
set @ds2:='2013-9-30';
select cast(a.village_moo as decimal) moo,a.village_name name,b.*
,if(b.target=0,0,b.total/b.target*100) percent
from village a
left join (select v.village_id
,count(distinct p.cid) target
,count(distinct if(s.women_service_id=1 and s.women_birth_control_id>0,s.person_women_service_id,null)) total
,count(distinct if(s.women_birth_control_id=0 or s.women_birth_control_id is null,s.person_women_service_id,null)) FP0
,count(distinct if(s.women_birth_control_id=1,s.person_women_service_id,null)) FP1
,count(distinct if(s.women_birth_control_id=2,s.person_women_service_id,null)) FP2
,count(distinct if(s.women_birth_control_id=3,s.person_women_service_id,null)) FP3
,count(distinct if(s.women_birth_control_id=4,s.person_women_service_id,null)) FP4
,count(distinct if(s.women_birth_control_id=5,s.person_women_service_id,null)) FP5
,count(distinct if(s.women_birth_control_id=6,s.person_women_service_id,null)) FP6
,count(distinct if(s.women_birth_control_id=7,s.person_women_service_id,null)) FP7
from person p
left join village v on p.village_id=v.village_id
left join person_women w on p.person_id=w.person_id
left join person_women_service s on w.person_women_id=s.person_women_id and s.service_date between @ds1 and @ds2 and s.women_service_id=1
where p.sex=2
and p.marrystatus=2
and p.house_regist_type_id in (1,3)
and timestampdiff(year,p.birthdate,@ds1) between 15 and 44
group by v.village_id) b on a.village_id=b.village_id
order by 1

64
ลองส่งตัวรายงานขึ้นมาคับ
จะได้ช่วยกันปรับ
*****
email/FB:=woravet12@hotmail.com

65
select s.service3,s.service4
,timediff(s.service3,s.service4) total
from service_time s
where s.vstdate between  "2010-10-01" and "2011-09-30"
and s.service3 is not null and s.service4 is not null

66
คุณต้องสร้างกลุ่มโรคที่ต้องการขึ้นมาก่อน
เช่น แบบ RPT_504_CODE/RPT_504_NAME
แล้วค่อยมาคำนวณ

67
select aa.an,lh.hn,concat(pt.pname,pt.fname,' ',pt.lname) ptname
,lh.department,lh.order_date,lh.lab_order_number,aa.bedno
from lab_head lh
left join iptadm aa on lh.vn=aa.an
left join patient pt on pt.hn=lh.hn
where lh.order_date='2013-12-11'
and lh.department='IPD'

68
select a.*,concat(pt.pname,pt.fname,' ',pt.lname) ptname
,s.vstdate,s.creatinine,s.egfr
,if (egfr>=90,'1'
,if (egfr>=60,'2'
,if (egfr>=30,'3'
,if (egfr>=15,'4'
,if (egfr>0,'5',''))))) stage
from (select max(s.vn) vn,c.hn
from clinicmember c
left join opdscreen s on c.hn=s.hn
where s.vstdate between '2013-10-01' and '2013-12-31'
and c.clinic=001 
and c.clinic_member_status_id=1
and s.creatinine>0
group by c.hn) a
left join patient pt on pt.hn=a.hn
left join opdscreen s on a.vn=s.vn

ถ้าเอาผล creatinine จาก opdscreen หล่ะ

69
set @cHN='';
select if(@cHN<>lh.hn,lh.hn,'') HN,@cHN:=lh.hn CheckHN,l.lab_items_name
,lo.lab_order_result,lh.order_department
from lab_head  lh
left join lab_order lo on lo.lab_order_number  = lh.lab_order_number
left join lab_items l on l.lab_items_code = lo.lab_items_code
where lh.order_date='2013-12-11'
and  lh.order_department=001
order by lh.hn
*****
เปลี่ยน deparment เอานะคับ

70
Report Exchange / Re: ขอตัวอย่าง MySQL COmmand ครับ
« เมื่อ: ธันวาคม 06, 2013, 14:24:56 PM »
select ifnull(r.refer_date,'รวม') date,count(*) 'case',sum(a.income) income
from referout r
left join an_stat a on r.vn=a.an
where r.refer_date between '2010-10-1' and '2011-9-30'
and r.department='IPD'
group by r.refer_date with rollup
*****
แบบนี้มั๊ย...ยังไม่เข้าใจเกี่ยวกับค่าใช้จ่ายรวมวันที่ 1...4
ลองเอาแบบฟอร์มมาดู

71
Report Exchange / Re: นำเวลามาลบกันใช้คำสั่งยังไงครับ
« เมื่อ: พฤศจิกายน 27, 2013, 10:23:31 AM »
ผมว่าไม่ database หรือไม่ก้อ windows ท่านมีปัญหาเกี่ยวกับวันที่
ตั้งแต่หาค่า dchdate is not null ของ clinicmember แล้ว
*****
คงต้องหาผู้รู้เกี่ยวกับเรื่องนี้

72
Report Exchange / Re: นำเวลามาลบกันใช้คำสั่งยังไงครับ
« เมื่อ: พฤศจิกายน 26, 2013, 14:45:27 PM »
แบบนี้มั๊ย
select date_format(service4,'%T') s4,date_format(service3,'%T') s3
,date_format(sec_to_time(time_to_sec(service4)-time_to_sec(service3)),'%T') ss
from service_time
where vstdate between "2010-10-01" and "2011-09-30"
เพราะไม่ทราบความต้องการที่แท้จริง

73
select 'LR' type,count(*) 'Total',sum(i.rw<0.5) 'CC'
from ipt i
left join iptdiag idx on i.an=idx.an
where idx.icd10 like 'O8%'
and i.dchdate between '2012-10-1' and '2013-9-30'

เนื่อง รพ. ผม เขาไม่ค่อยลงทำเบียนคลอดกัน เลยจับที่ diag เอา
ซึ่งที่จริงน่าจะจับที่ ipt_pregnancy ที่ deliver_type in (1,2)

74
icdname() เป็น Stored Function แสดงชื่อโรคที่ผมสร้างขึ้น
เพราะถ้า join ตรงกับ icd101 แล้วมีรหัสที่ขึ้นต้นด้วย M,V-Y ชื่อโรคไม่ตรงตามต้องการ
แผนแพทย์ไทยส่วนใหญ่ diag น่าจะขึ้นด้วย M
*****
เอารายการนี้ออกก่อนก้อได้

75
select clinicmember_id,clinic,hn,clinic_member_status_id,dchdate,send_to_pcu
from clinicmember
where clinic_member_status_id="1" and dchdate <> "" and dchdate is not null

76
select p.person_id,p.pname,p.fname,p.lname,vss.age_y age
,address(p.patient_hn) address
,s.school_name school
,vsc.village_school_class_name class
,vs.school_room_no room
,vss.screen_date
,cast(vss.body_weight as signed) bw,cast(vss.height as signed) height
,l1.name nutrition_level
,l2.name height_level
,l3.name bmi_level
from village_student vs
left join person p on p.person_id=vs.person_id
left join village_school_class vsc on vsc.village_school_class_id=vs.village_school_class_id
left join village_school s on s.village_school_id=vs.village_school_id
left join village_student_screen vss on vss.village_student_id=vs.village_student_id
left join nutrition_level l1 on l1.nutrition_level=vss.nutrition_level
left join height_level l2 on l2.height_level=vss.height_level
left join bmi_level l3 on l3.bmi_level=vss.bmi_level
order by p.person_id,vss.screen_date desc

77
select concat(pt.pname,pt.fname,' ',pt.lname) ptname
,timestampdiff(year,pt.birthday,now()) age,anc.ga,s.hn,s.an,pt.cid
,s.service_date,if(s.an is null,v.pdx,a.pdx) pdx,icdname(if(s.an is null,v.pdx,a.pdx)) disease
,o.health_med_operation_item_name
from health_med_service s
left join patient pt on pt.hn=s.hn
left join person p on p.cid=pt.cid
left join person_anc anc on p.person_id=anc.person_id
left join vn_stat v on s.vn=v.vn
left join an_stat a on s.an=a.an
left join health_med_service_operation so on so.health_med_service_id=s.health_med_service_id
left join health_med_operation_item o on o.health_med_operation_item_id=so.health_med_operation_item_id
where s.service_date between '2013-6-1' and '2013-6-30'
and o.health_med_operation_item_name regexp 'หลังคลอด'
order by s.hn,s.service_date
แบบนี้หล่ะ....พอดีไม่มีข้อมูลทดสอบ

78
แบบนี้รึป่าว
select 'OVST' type,o.vn
from ovst o
left join vn_stat v on o.vn=v.vn
where v.vn is null

union all
select 'VN_STAT' type,v.vn
from vn_stat v
left join ovst o on o.vn=v.vn
where o.vn is null

79
ตาม อ.เกื้อ ถูกต้องแล้วครับ
แต่เนื่องจากเราไม่ทราบว่า..ข้อมูลไม่เท่ากันวันไหน..ต้องทำไปเรื่อยๆ
ไม่รู้ อ.MN มี tool แบบ resynchonize ทั้งปีรึป่าว
ถ้า ovst มากกว่า vn_stat ก้อยังถือว่าถูกต้อง

80
เขียน stored function ไว้ใช้เอง
create function ThaiDate (param1 date) returns varchar(40)
begin
   declare cdate varchar(40);
   declare nmonth int;
   declare cmonth varchar(40);
   declare i int default 0;
   set nmonth=month(param1);
   set cmonth='';
   set cmonth=if(nmonth=1,'มกราคม',cmonth);
   set cmonth=if(nmonth=2,'กุมภาพันธ์',cmonth);
   set cmonth=if(nmonth=3,'มีนาคม',cmonth);
   set cmonth=if(nmonth=4,'เมษายน',cmonth);
   set cmonth=if(nmonth=5,'พฤษภาคม',cmonth);
   set cmonth=if(nmonth=6,'มิถุนายน',cmonth);
   set cmonth=if(nmonth=7,'กรกฎาคม',cmonth);
   set cmonth=if(nmonth=8,'สิงหาคม',cmonth);
   set cmonth=if(nmonth=9,'กันยายน',cmonth);
   set cmonth=if(nmonth=10,'ตุลาคม',cmonth);
   set cmonth=if(nmonth=11,'พฤศจิกายน',cmonth);
   set cmonth=if(nmonth=12,'ธันวาคม',cmonth);
   set cdate=concat(day(param1),' ',cmonth,' ',year(param1)+543);
   set cdate=replace(cdate,'0','๐');
   set cdate=replace(cdate,'1','๑');
   set cdate=replace(cdate,'2','๒');
   set cdate=replace(cdate,'3','๓');
   set cdate=replace(cdate,'4','๔');
   set cdate=replace(cdate,'5','๕');
   set cdate=replace(cdate,'6','๖');
   set cdate=replace(cdate,'7','๗');
   set cdate=replace(cdate,'8','๘');
   set cdate=replace(cdate,'9','๙');
   return cdate;
end;

81
แจ้งปัญหา / ขอความช่วยเหลือ / Re: Adjusted RW
« เมื่อ: กันยายน 18, 2013, 11:56:06 AM »
select ps.pttype_spp_name,count(i.an) 'case',sum(a.income) income
,sum(i.rw=0) rw0
,sum(i.rw) Sum_RW
,sum(i.adjrw) sum_Adjrw
,avg(i.adjrw) CMI
from ipt i
left join an_stat a on a.an=i.an
left join pttype p on i.pttype=p.pttype
left join pttype_spp ps on p.pttype_spp_id=ps.pttype_spp_id
where i.dchdate between '2012-10-1' and '2013-9-30'
group by p.pttype_spp_id

ดู rw=0 ตรง RW0 ด้วยนะคับ เพราะจะทำให้ค่าออกมา error

82
การเขียน SQL Script / Re: ผู้ป่วย Re-admit
« เมื่อ: กันยายน 11, 2013, 16:42:59 PM »
select *
from an_stat
where dchdate between '2013-1-1' and '2013-1-31'
and lastvisit<=28

83
Report Exchange / Re: ขอรายงานยาผู้ป่วยโรคซึมเศร้า
« เมื่อ: สิงหาคม 29, 2013, 12:51:47 PM »
select v.vstdate,v.vn,v.hn,v.cid,concat(pt.pname,pt.fname) Fname,pt.Lname
,p.name pttypename
,pt.addrpart addressno,cast(v.moopart as signed) moo,t.full_name address
,odx.icd10
,group_concat(concat(d.name,' ',d.strength,'#',o.qty) separator '|') drug
from vn_stat v
left join patient pt on pt.hn=v.hn
left join ovstdiag odx on odx.vn=v.vn
left join pttype p on v.pttype=p.pttype
left join thaiaddress t on v.aid=t.addressid
left join opitemrece o on o.vn=v.vn
left join drugitems d on o.icode=d.icode
where v.vstdate between '2013-1-1' and '2013-1-31'
and odx.icd10 between 'F00' and 'F9999'
and d.name is not null
group by v.vn

84
Report Exchange / Re: แบบฟอร์ม Family Floder
« เมื่อ: สิงหาคม 09, 2013, 16:01:25 PM »
ที่ออกหน้าขาว...เพราะว่าถูก fix เรื่องอายุ
และ house_regist_type_id

85
Report Exchange / Re: ดึงข้อมูล ยานอก ยาใน ยังไงดีครับ
« เมื่อ: สิงหาคม 02, 2013, 15:38:32 PM »
select icode itemid,concat(name,' ',strength) item,units unit,unitprice,if(drugaccount='','17','03') chargeid from drugitems
มันไม่มีสมุนไพรด้วยเหรอ

86
ผมลองใช้ ShapeFillColor(hsf,j)=rgb(255,0,0) เพื่อกำหนดสีแต่ละ shape ไม่ได้

87
อ.MN มี shapefile ของแต่ละจังหวัด/อำเภอ/ตำบล/หมู่บ้านไหมครับ

88
1.นอก/ในเวลา
select count(x.vn) total
,sum(dayofweek(x.request_date) in (1,7)
or h.holiday_date is not null
or x.request_time<'08:00:00'
or x.request_time>'16:00:00') outtime
,sum(!(dayofweek(x.request_date) in (1,7)
or h.holiday_date is not null
or x.request_time<'08:00:00'
or x.request_time>'16:00:00')) intime
from xray_report x
left  join holiday h on h.holiday_date=x.request_date
where x.request_date between '2013-1-1' and '2013-1-31'

2.OPD/IPD
select count(x.vn) total
,sum(length(an)<>9) 'OPD'
,sum(length(an)=9) 'IPD'
from xray_report x
where x.request_date between '2013-1-1' and '2013-1-31'

89
การเขียน SQL Script / Re: ตรวจ CBC
« เมื่อ: กรกฎาคม 16, 2013, 12:28:16 PM »
select order_date
,count(vn) Total
,sum(sub_group_list regexp '12' or sub_group_list regexp '81' or sub_group_list regexp '87' ) CBC
,sum(sub_group_list regexp '33' or sub_group_list regexp '89' ) UA
from lab_head lh
where lh.order_date between '2013-1-1' and '2013-1-31'
group by order_date
แก้รหัส CBC กับ UA เอานะ
อย่าง CBC ผมมี 3 รหัส UA มี 2 รหัส

90
Report Exchange / Re: รายงานแยกตามสิทธิ
« เมื่อ: กรกฎาคม 03, 2013, 15:19:35 PM »
แก้ให้ตรงกับเงื่อนไขของตาราง pttype_spp ครับ
*****
set @ds1:='2012-10-1';
set @ds2:='2012-10-1';
select lo.lab_items_code code,lo.lab_items_name_ref name
,count(*) 'Total'
,ifnull(sum(p.pcode in ('A2')),0)  'A2'
,ifnull(sum(p.pcode in ('A7')),0) 'A7'
,ifnull(sum(p.pcode in ('AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','UC')),0) 'UC'
,ifnull(sum(p.pcode in ('AL')),0) as 'AL'
,ifnull(sum(p.pcode not in ('A2','A7','AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','UC') or p.pcode is null),0) 'Other'
from lab_head lh
left join lab_order lo on lo.lab_order_number=lh.lab_order_number
left join ovst o on o.vn=lh.vn
left join pttype p on p.pttype=o.pttype
where lh.order_date between @ds1 and @ds2
group by lo.lab_items_code
order by name

91
Report Exchange / Re: รายงานแยกตามสิทธิ
« เมื่อ: กรกฎาคม 02, 2013, 11:18:30 AM »
set @ds1:='2012-10-1';
set @ds2:='2012-10-1';
select lo.lab_items_code code,lo.lab_items_name_ref name
,count(*) 'Total'
,ifnull(sum(p.pttype_spp_id in (1)),0) 'A2'
,ifnull(sum(p.pttype_spp_id in (2)),0) 'A7'
,ifnull(sum(p.pttype_spp_id in (3,4)),0) 'UC'
,ifnull(sum(p.pttype_spp_id in (5)),0) 'AL'
,ifnull(sum(p.pttype_spp_id not in (1,2,3,4,5) or p.pttype_spp_id is null),0) 'Other'
from lab_head lh
left join lab_order lo on lo.lab_order_number=lh.lab_order_number
left join ovst o on o.vn=lh.vn
left join pttype p on p.pttype=o.pttype
where lh.order_date between @ds1 and @ds2
group by lo.lab_items_code
order by name

ระวัง..ไม่ควรทำช่วงเวลากว้างๆ ทำเป็นรายวันจะดีกว่า
กรุณาตรวจสอบฟิล์ด pttype_spp_id ที่ตาราง pttype ด้วย
ว่าถูกต้องตามตาราง pttype_spp มั๊ย

92
คุณเอาข้อมูลมาแสดงจากส่วนไหน
ถ้าจาก vn_stat ลองเปลี่ยนเป็น
select vn
,sum(odx.icd10 not regexp '^[0-9]') 'dx'
,sum(odx.icd10 regexp '^[0-9]') 'op'
from ovstdiag odx
where odx.vstdate='2013-7-1'
group by odx.vn

93
ผมทำ store function แล้ว ภาษาไทยรู้สึกว่าจะเป็น utf8 ไม่ใช่ tis620
ทั้งที่กำหนด returns เป้น tis620 แล้ว

94
select o.vstdate
,sum(sum_price) 'total'
,sum(if(paidst='00',sum_price,0)) 'Paidst00'
,sum(if(paidst='01',sum_price,0)) 'Paidst01'
,sum(if(paidst='02',sum_price,0)) 'Paidst02'
,sum(if(paidst='03',sum_price,0)) 'Paidst03'
,sum(if(paidst='04',sum_price,0)) 'Paidst04'
from opitemrece o
where vstdate between '2012-10-1' and '2012-10-31'
and vn is not null
group by vstdate

***ดูตาราง PAIDST ประกอบ***

95
การเขียน SQL Script / Re: CMI แยกตามสิทธิ์
« เมื่อ: มิถุนายน 20, 2013, 15:56:23 PM »
select p2.pttype_spp_name name
,avg(adjrw) cmi
from ipt i
left join pttype p1 on i.pttype=p1.pttype
left join pttype_spp p2 on p2.pttype_spp_id-p1.pttype_spp_id
where dchdate between '2012-10-1' and '2013-4-30'
group by p2.pttype_spp_id

96
การเขียน SQL Script / Re: การดึงคนไข้ URI+AGE
« เมื่อ: มิถุนายน 18, 2013, 14:22:23 PM »
select v.hn,pt.pname,pt.fname,pt.lname,count(v.hn) cc
,cast(group_concat(distinct v.vstdate) as char(200)) date
from vn_stat v
left join patient pt on pt.hn=v.hn
left join ovstdiag odx on odx.vn=v.vn
where v.vstdate between '2012-10-1' and '2013-9-30'
and odx.icd10 in ('B053', 'H650')
group by v.hn
having cc>1
เพิ่ม icd10 เอานะคับ

97
order_date ไม่ใช่อยู่ที่ตาราง lab_head เหรอ

98
select year(a.nextdate)+543 year,month(a.nextdate) month
,count(a.vn) 'case'
,count(if(a.patient_visit='Y',a.vn,null)) 'confirm'
,count(if(a.patient_visit<>'Y' or a.patient_visit is null,a.vn,null)) 'no'
from oapp a
where a.nextdate between '2012-10-1' and '2013-9-30'
group by year,month

99
ประมาณนี้มั๊ย
select k.department,count(distinct o.hn) 'case',count(o.hn) 'visit'
from ovst o
left join kskdepartment k on k.depcode=o.main_dep
where o.vstdate between '2012-10-1' and '2013-9-30'
group by o.main_dep
*****
แต่ถ้าเป็น UnitCost คงไม่ใช่

100
select count(nb.an) 'target'
,sum(apgar1<=7 or has_asphyxia='Y') 'result'
,sum(apgar1<=7 or has_asphyxia='Y')/count(nb.an)*1000 'percent'
from ipt_newborn nb
where nb.born_date between '2012-10-1' and '2013-9-30'

หน้า: 1 [2] 3 4 ... 9