ผู้เขียน หัวข้อ: ฝากให้พี่ขวดช่วยทดสอบครับ  (อ่าน 5055 ครั้ง)

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

ออฟไลน์ golf_win

  • Hero Member
  • *****
  • กระทู้: 3,481
  • Respect: +112
    • ดูรายละเอียด
ฝากให้พี่ขวดช่วยทดสอบครับ
« เมื่อ: มกราคม 17, 2009, 20:03:02 PM »
0
พี่ขวดครับผมดูผิดจริงๆ เป็นรายงานที่ผสมกันระหว่าง SQL กับ Variable ครับ ;D ;D
โรงพยาบาลเจ็ดเสมียน จังหวัดราชบุรี
Start 19-1-51    35 station
HOSxP  3.59.5.18 Activate License
Tel. 032-305096-7 ต่อ 118
Web. http://csmhos.thaiddns.com:8080
         http://csmhos.thaieasydns.com:8080

ออฟไลน์ golf_win

  • Hero Member
  • *****
  • กระทู้: 3,481
  • Respect: +112
    • ดูรายละเอียด
Re: ฝากให้พี่ขวดช่วยทดสอบครับ
« ตอบกลับ #1 เมื่อ: มกราคม 17, 2009, 20:16:12 PM »
0
อีกอย่างเป็นรายงานที่ตัดยอดแบบ realtime ถ้ามี colum วันที่บันทึกข้อมูลในตาราง person น่าจะทำให้ดึงรายงานย้อนหลังได้นะครับ ;D ;D
« แก้ไขครั้งสุดท้าย: มกราคม 17, 2009, 20:21:08 PM โดย golf_win »
โรงพยาบาลเจ็ดเสมียน จังหวัดราชบุรี
Start 19-1-51    35 station
HOSxP  3.59.5.18 Activate License
Tel. 032-305096-7 ต่อ 118
Web. http://csmhos.thaiddns.com:8080
         http://csmhos.thaieasydns.com:8080

doramon

  • บุคคลทั่วไป
Re: ฝากให้พี่ขวดช่วยทดสอบครับ
« ตอบกลับ #2 เมื่อ: มกราคม 17, 2009, 21:59:54 PM »
0
เอาไปใช้ด้วย  ;D

ออฟไลน์ มนตรี บอยรักยุ้ยคนเดียว

  • Hero Member
  • *****
  • กระทู้: 5,369
  • Respect: +12
    • ดูรายละเอียด
    • โรงพยาบาลชุมชน ด่านมะขามเตี้ย
Re: ฝากให้พี่ขวดช่วยทดสอบครับ
« ตอบกลับ #3 เมื่อ: มกราคม 18, 2009, 18:44:07 PM »
0
 ;D ;D ;D ;D ;D ;D
เริ่ม11พย.2548OPD-Paperlessพร้อมHOSxPลดโลกร้อน
FF-Paperless(รพ.สค.)เริ่ม1ตค2555=100%
IPD-Lesspaper1ตค2560ระบบDmsByNeoNetwork
IPD-Paperless1พ.ค2562ระบบHOSxPXE4
ServerMTOL8.5+MDB-10.4.20,SlaveOL8.5+MDB-10.7.3
LOG=PostgreSQL11,INV=PostgreSQL11

ออฟไลน์ Khuad

  • Hero Member
  • *****
  • กระทู้: 3,778
  • .. นางฟ้า ตัวไม่น้อยแล้ว ..
  • Respect: +10
    • ดูรายละเอียด
Re: ฝากให้พี่ขวดช่วยทดสอบครับ
« ตอบกลับ #4 เมื่อ: มกราคม 19, 2009, 10:20:44 AM »
0

... ลองใช้คำสั่งข้างล่าง RUN ใน HOSxP ดูนะครับ ...

... กลุ่มอายุจะใช้วันเกิดมาคำนวณ  ไม่ได้ใช้ age_y จากตาราง person  ก็จะทำให้ดึงข้อมูลมาดูเมื่อไรก็ได้ โดยไม่ต้องไปสั่ง Update Age ก่อน...

...ถ้าต้องการเปลี่ยนแปลงเงื่อนไขที่ต้องการดู ก็แก้ไขเพิ่มเติมตรง where ได้เลยครับ ....  :D ....



select p.village_id, v.village_moo as "หมู่ที่",v.village_name as "ชื่อหมู่บ้าน",
count(pt.person_id) as "รวมทั้งหมด",
count(pm.person_id) as "รวม(ช.)", count(pf.person_id) as "รวม(ญ.)",
count(p1.person_id) as "ต่ำกว่า 1 ปี(ช.)", count(p2.person_id) as "ต่ำกว่า 1 ปี(ญ.)",
count(p3.person_id) as "1-4 ปี(ช.)", count(p4.person_id) as "1-4 ปี(ญ.)",
count(p5.person_id) as "5-9 ปี(ช.)", count(p6.person_id) as "5-9 ปี(ญ.)",
count(p7.person_id) as "10-14 ปี(ช.)", count(p8.person_id) as "10-14 ปี(ญ.)",
count(p9.person_id) as "15-19 ปี(ช.)", count(p10.person_id) as "15-19 ปี(ญ.)",
count(p11.person_id) as "20-24 ปี(ช.)", count(p12.person_id) as "20-24 ปี(ญ.)",
count(p13.person_id) as "25-29 ปี(ช.)", count(p14.person_id) as "25-29 ปี(ญ.)",
count(p15.person_id) as "30-34 ปี(ช.)", count(p16.person_id) as "30-34 ปี(ญ.)", 
count(p17.person_id) as "35-39 ปี(ช.)", count(p18.person_id) as "35-39 ปี(ญ.)",
count(p19.person_id) as "40-44 ปี(ช.)", count(p20.person_id) as "40-44 ปี(ญ.)",
count(p21.person_id) as "45-49 ปี(ช.)", count(p22.person_id) as "45-49 ปี(ญ.)",
count(p23.person_id) as "50-54 ปี(ช.)", count(p24.person_id) as "50-54 ปี(ญ.)",
count(p25.person_id) as "55-59 ปี(ช.)", count(p26.person_id) as "55-59 ปี(ญ.)",
count(p27.person_id) as "60-64 ปี(ช.)", count(p28.person_id) as "60-64 ปี(ญ.)",
count(p29.person_id) as "65-69 ปี(ช.)", count(p30.person_id) as "65-69 ปี(ญ.)",
count(p31.person_id) as "70-74 ปี(ช.)", count(p32.person_id) as "70-74 ปี(ญ.)",
count(p33.person_id) as "75-79 ปี(ช.)", count(p34.person_id) as "75-79 ปี(ญ.)",
count(p35.person_id) as "80-84 ปี(ช.)", count(p36.person_id) as "80-84 ปี(ญ.)",
count(p37.person_id) as "85 ปีขึ้นไป(ช.)", count(p38.person_id) as "85 ปีขึ้นไป(ญ.)",
count(p39.person_id) as "ไม่ทราบอายุ(ช.)", count(p40.person_id) as "ไม่ทราบอายุ(ญ.)"

from person p

left outer join village v on v.village_id = p.village_id

left outer join person pt on pt.person_id = p.person_id
left outer join person pm on pm.person_id = p.person_id and p.sex = '1'
left outer join person pf on pf.person_id = p.person_id and p.sex = '2'

left outer join person p1 on p1.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) < '1' and p.sex = '1'
left outer join person p2 on p2.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) < '1' and p.sex = '2'

left outer join person p3 on p3.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '1' and '4' and p.sex = '1'
left outer join person p4 on p4.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '1' and '4' and p.sex = '2'

left outer join person p5 on p5.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '5' and '9' and p.sex = '1'
left outer join person p6 on p6.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '5' and '9' and p.sex = '2'

left outer join person p7 on p7.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '10' and '14' and p.sex = '1'
left outer join person p8 on p8.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '10' and '14' and p.sex = '2'

left outer join person p9 on p9.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '15' and '19' and p.sex = '1'
left outer join person p10 on p10.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '15' and '19' and p.sex = '2'

left outer join person p11 on p11.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '20' and '24' and p.sex = '1'
left outer join person p12 on p12.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '20' and '24' and p.sex = '2'

left outer join person p13 on p13.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '25' and '29' and p.sex = '1'
left outer join person p14 on p14.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '25' and '29' and p.sex = '2'

left outer join person p15 on p15.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '30' and '34' and p.sex = '1'
left outer join person p16 on p16.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '30' and '34' and p.sex = '2'

left outer join person p17 on p17.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '35' and '39' and p.sex = '1'
left outer join person p18 on p18.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '35' and '39' and p.sex = '2'

left outer join person p19 on p19.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '40' and '44' and p.sex = '1'
left outer join person p20 on p20.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '40' and '44' and p.sex = '2'

left outer join person p21 on p21.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '45' and '49' and p.sex = '1'
left outer join person p22 on p22.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '45' and '49' and p.sex = '2'

left outer join person p23 on p23.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '50' and '54' and p.sex = '1'
left outer join person p24 on p24.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '50' and '54' and p.sex = '2'

left outer join person p25 on p25.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '55' and '59' and p.sex = '1'
left outer join person p26 on p26.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '55' and '59' and p.sex = '2'

left outer join person p27 on p27.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '60' and '64' and p.sex = '1'
left outer join person p28 on p28.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '60' and '64' and p.sex = '2'

left outer join person p29 on p29.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '65' and '69' and p.sex = '1'
left outer join person p30 on p30.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '65' and '69' and p.sex = '2'

left outer join person p31 on p31.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '70' and '74' and p.sex = '1'
left outer join person p32 on p32.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '70' and '74' and p.sex = '2'

left outer join person p33 on p33.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '75' and '79' and p.sex = '1'
left outer join person p34 on p34.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '75' and '79' and p.sex = '2'

left outer join person p35 on p35.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '80' and '84' and p.sex = '1'
left outer join person p36 on p36.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) between '81' and '84' and p.sex = '2'

left outer join person p37 on p37.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) > '84' and p.sex = '1'
left outer join person p38 on p38.person_id = p.person_id
and timestampdiff(year,p.birthdate,curdate()) > '84' and p.sex = '2'

left outer join person p39 on p39.person_id = p.person_id
and (p.birthdate is null  or p.birthdate = '')  and p.sex = '1'
left outer join person p40 on p40.person_id = p.person_id
and (p.birthdate is null  or p.birthdate = '')  and p.sex = '2'

where p.village_id <> '1' and p.citizenship = '99'

group by p.village_id
order by p.village_id

โรงพยาบาลวังน้อย   พระนครศรีอยุธยา ( รพช.30 เตียง )
Server : ProLiant DL120G6  Xeon X3450  RDIMM 12 Gb  2x256GB SSD Raid 1
OS : CentOS 6.3  DB : Percona 5.5.21

Slave : ProLiant ML110G6  Xeon X3430  UDIMM 8 Gb  2x300GB SAS Raid 1
OS : CentOS 6.3  DB : Percona 5.5.32

HOSxP version  3.57.xx.xx    เริ่มระบบ  เมษายน 2549

ออฟไลน์ thannawe

  • Hero Member
  • *****
  • กระทู้: 2,904
  • Respect: +8
    • ดูรายละเอียด
Re: ฝากให้พี่ขวดช่วยทดสอบครับ
« ตอบกลับ #5 เมื่อ: มกราคม 19, 2009, 10:29:56 AM »
0
เป็น script SQL ที่ยาวมากเลยครับ
อ.ขวด ยาวมากเลยครับ   :D ;D
สุดยอดจริงๆ  ยังไม่เคยเห็นยาวขนาดนี้มาก่อน ;D :D ;D
กิจจา ชาญธัญกรรม
นักวิชาการคอมพิวเตอร์ชำนาญการ รพ.โพธาราม จ.ราชบุรี
็HOSxP XE

ออฟไลน์ Khuad

  • Hero Member
  • *****
  • กระทู้: 3,778
  • .. นางฟ้า ตัวไม่น้อยแล้ว ..
  • Respect: +10
    • ดูรายละเอียด
Re: ฝากให้พี่ขวดช่วยทดสอบครับ
« ตอบกลับ #6 เมื่อ: มกราคม 19, 2009, 10:37:37 AM »
0

... อันนี้เป็นตัวรายงานที่พี่ลองทำดู  เป็นรายงานที่ใช้คำสั่ง sql ล้วนๆ เลย   รูปแบบรายงานลอกมาจาก HCIS ...

... และถ้าต้องการเปลี่ยนแปลงเงื่อนไขของข้อมูลที่ต้องการดู ก็แก้ไขจากคำสั่งของรายงานได้เลย ไม่ต้องแก้ที่ตัวรายงาน  ลองทดสอบดูนะครับ ...  :D ....
โรงพยาบาลวังน้อย   พระนครศรีอยุธยา ( รพช.30 เตียง )
Server : ProLiant DL120G6  Xeon X3450  RDIMM 12 Gb  2x256GB SSD Raid 1
OS : CentOS 6.3  DB : Percona 5.5.21

Slave : ProLiant ML110G6  Xeon X3430  UDIMM 8 Gb  2x300GB SAS Raid 1
OS : CentOS 6.3  DB : Percona 5.5.32

HOSxP version  3.57.xx.xx    เริ่มระบบ  เมษายน 2549

ออฟไลน์ thecoy

  • Hero Member
  • *****
  • กระทู้: 1,159
  • นักวิชาการคอมพิวเตอร์
  • Respect: 0
    • ดูรายละเอียด
Re: ฝากให้พี่ขวดช่วยทดสอบครับ
« ตอบกลับ #7 เมื่อ: มกราคม 19, 2009, 10:42:28 AM »
0
สุดยอดครับพี่ khuad ขยันจริงๆๆๆๆ
โรงพยาบาลรัษฎา  ตรัง
CentOS 5.5  Ram  4  GB
HOSxP V.3.54.11.2 MySQL 5.1.30

ออฟไลน์ Khuad

  • Hero Member
  • *****
  • กระทู้: 3,778
  • .. นางฟ้า ตัวไม่น้อยแล้ว ..
  • Respect: +10
    • ดูรายละเอียด
Re: ฝากให้พี่ขวดช่วยทดสอบครับ
« ตอบกลับ #8 เมื่อ: มกราคม 19, 2009, 14:44:27 PM »
0

เป็น script SQL ที่ยาวมากเลยครับ
อ.ขวด ยาวมากเลยครับ   :D ;D
สุดยอดจริงๆ  ยังไม่เคยเห็นยาวขนาดนี้มาก่อน ;D :D ;D


.... จริงๆ แล้ว  ป๋า jdadmin1    กะ   ป๋า udomchok    2 คนน่ะยาวกว่าพี่อีกนะน้องกิจ ....

.... อายุ กะ สายตา นะ     2 ป๋าข้างบนน่ะยาวกว่าพี่เยอะเลย ....  ;D  ;D  ;D  ;D  ;D ......
โรงพยาบาลวังน้อย   พระนครศรีอยุธยา ( รพช.30 เตียง )
Server : ProLiant DL120G6  Xeon X3450  RDIMM 12 Gb  2x256GB SSD Raid 1
OS : CentOS 6.3  DB : Percona 5.5.21

Slave : ProLiant ML110G6  Xeon X3430  UDIMM 8 Gb  2x300GB SAS Raid 1
OS : CentOS 6.3  DB : Percona 5.5.32

HOSxP version  3.57.xx.xx    เริ่มระบบ  เมษายน 2549

ออฟไลน์ udomchok

  • Hero Member
  • *****
  • กระทู้: 8,347
  • Respect: +589
    • ดูรายละเอียด
    • ร.พ.สมเด็จพระสังฆราช องค์ที่ 17
Re: ฝากให้พี่ขวดช่วยทดสอบครับ
« ตอบกลับ #9 เมื่อ: มกราคม 19, 2009, 21:18:21 PM »
0
อ.ขวด ยาวมากเลยครับ   :D ;D
สุดยอดจริงๆ  ยังไม่เคยเห็นยาวขนาดนี้มาก่อน ;D :D ;D
แหม...อ่านแค่นี้แล้วรู้สึก..... ไม่อยากจะเชื่อเลยว่า อ.ขวด ตัวแต่นี้ แต่....ยาววววววววววจริง ๆ 555555555555
ทำด้วยหัวใจร.พ.สมเด็จพระสังฆราช องค์ที่ 17 อ.สองพี่น้อง จ.สุพรรณบุรี
อบรมโดย BMS Team เมื่อ พ.ย. 49 ขึ้นระบบห้องบัตรเมื่อ X'Mas 2007
2008 : X-Ray กายภาพบำบัด แพทย์แผนไทย กิจกรรมบำบัด OPD ตา
2009 : ทันตกรรม ห้องตรวจตา OPD (พยาบาลและห้องตรวจแพทย์บางห้อง)