ผู้เขียน หัวข้อ: ช่วยดู Code รายงานทันตให้หน่อยจ้า  (อ่าน 2848 ครั้ง)

0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

ออฟไลน์ prapansak

  • Full Member
  • ***
  • กระทู้: 232
  • Respect: 0
    • ดูรายละเอียด
    • http://118.175.76.8/bl/
ช่วยดู Code รายงานทันตให้หน่อยจ้า
« เมื่อ: เมษายน 22, 2013, 11:30:02 AM »
0
มีปัญหาว่าติดตรงที่ต้องการแยกอายุด้วย เช่น 0-4 ปี 3-5 ปี แต่ผมหาวิธีแยกอายุไม่ได้ครับ
โรงพยาบาลบ้านเหลื่อม โรงพยาบาลขนาด 30 เตียง
OS : Linux Cenos 5 
Server : hp
Ram : 16 G
นายประพันธ์ศักดิ์ พันศรี (นักวิชาการคอมพิวเตอร์)
E-mail blhospital@hotmail.com

ออฟไลน์ prapansak

  • Full Member
  • ***
  • กระทู้: 232
  • Respect: 0
    • ดูรายละเอียด
    • http://118.175.76.8/bl/
Re: ช่วยดู Code รายงานทันตให้หน่อยจ้า
« ตอบกลับ #1 เมื่อ: เมษายน 22, 2013, 11:48:56 AM »
0
select v.hospsub,h.name ,count(distinct(d.hn)),count(d.hn),sum(v.age_y between '0' and '4' )  as "þ.¤¹"
from dtmain d
left outer join vn_stat v on v.vn = d.vn
left outer join hospcode h on h.hospcode=v.hospsub
where d.vstdate between '2013-01-01' and '2013-01-31' and v.hospmain=10874 and hospsub<>""
group by v.hospsub

ได้แล้วแบบ งง
ผมลองเปลี่ยน จาก count เป็น sum ได้เฉยเลย งง โค๊ดผมถูกไหมครับ ดูให้ที
select v.hospsub,h.name ,count(distinct(d.hn)),count(d.hn),sum(v.age_y between '0' and '4' )  as "&Atilde;&frac34;.&curren;&sup1;"
from dtmain d
left outer join vn_stat v on v.vn = d.vn
left outer join hospcode h on h.hospcode=v.hospsub
where d.vstdate between '2013-01-01' and '2013-01-31' and v.hospmain=10874 and hospsub<>""
group by v.hospsub
โรงพยาบาลบ้านเหลื่อม โรงพยาบาลขนาด 30 เตียง
OS : Linux Cenos 5 
Server : hp
Ram : 16 G
นายประพันธ์ศักดิ์ พันศรี (นักวิชาการคอมพิวเตอร์)
E-mail blhospital@hotmail.com

ออฟไลน์ samcom2

  • Newbie
  • *
  • กระทู้: 6
  • Respect: 0
    • ดูรายละเอียด
Re: ช่วยดู Code รายงานทันตให้หน่อยจ้า
« ตอบกลับ #2 เมื่อ: เมษายน 23, 2013, 14:06:12 PM »
0
select v.hospsub,h.name ,count(distinct(d.hn)) as kon,count(distinct(d.vn)) as krung, count(d.hn) as ngan,
 count(distinct(case when v.age_y <= 2 then d.vn  end) ) as age_0_2,
 count(distinct(case when v.age_y >= 3 and v.age_y <= 5 then d.vn  end) ) as age_3_5,
 count(distinct(case when v.age_y >= 6 and v.age_y <= 14 then d.vn  end) ) as age6_14,
 count(distinct(case when v.age_y >= 15 and v.age_y <= 40 then d.vn  end) ) as age15_40,
 count(distinct(case when v.age_y >= 41 and v.age_y <= 59 then d.vn  end) ) as age41_59,
 count(distinct(case when v.age_y >= 60 then d.vn  end) ) as age_60more
from dtmain d
left outer join vn_stat v on v.vn = d.vn
left outer join hospcode h on h.hospcode=v.hospsub
where d.vstdate between '2013-01-01' and '2013-01-31' and v.hospmain=10874 and hospsub<>""
group by v.hospsub
OS : debian 64 bit  mysql5.5
Server : pc ประกอบ
Ram : 64 G
นายณรงศักดิ์ ทองคำ นวก.สาธารณสุข รพ.สามพราน