Moderator Control Panel ]

รายงานคน ใหม่ เก่า ในปี ในเขตอ.รับผิดชอบ

เรื่องรายงาน SQL command แลกเปลี่ยน รายงาน

Moderator: zatanofmonk, julaluk, thiwatip, bigdevil88

รายงานคน ใหม่ เก่า ในปี ในเขตอ.รับผิดชอบ

โพสต์ใหม่โดย pakee_06 » พฤหัสฯ. 30 มิ.ย. 2011 11:41 am

เห็นช่วงนี้ นครสวรรค์ขอรายงานนี้มา วันนี้เลยเอามาแปะให้ค่ะ ให้พี่ๆ ช่วยตรวจสอบว่าถูกต้องหรือเปล่า

โค้ด: เลือกทั้งหมด
SELECT q1.visit as  type
,max(q1.opd_in_cup) as opd_in_cup
,max(q1.opd_out_cup) as opd_out_cup
,max(q1.ipd_in_cup) as ipd_in_cup
,max(q1.ipd_out_cup) as ipd_out_cup
,sum(q1.opd_in_cup + q1.opd_out_cup + q1.ipd_in_cup + q1.ipd_out_cup) as รวม

FROM
(select case when t_visit.visit_first_visit = '1' then 'ผู้ป่วยใหม่'
            when t_visit.visit_first_visit = '0' then 'ผู้ป่วยเก่า'
            end as visit

        ,count(distinct case when t_patient.patient_amphur = '601100' and t_visit.f_visit_type_id = '0' then t_visit.t_patient_id else null end) as opd_in_cup
        ,count(distinct case when t_patient.patient_amphur <> '601100' and t_visit.f_visit_type_id = '0' then t_visit.t_patient_id else null end) as opd_out_cup
        ,count(distinct case when t_patient.patient_amphur = '601100' and t_visit.f_visit_type_id = '1' then t_visit.t_patient_id else null end) as ipd_in_cup
        ,count(distinct case when t_patient.patient_amphur <> '601100' and t_visit.f_visit_type_id = '1' then t_visit.t_patient_id else null end) as ipd_out_cup


        ,count(distinct case when t_visit.f_visit_type_id = '0' then t_visit.t_patient_id else null end) as opd
        ,count(distinct case when t_visit.f_visit_type_id = '1' then t_visit.t_patient_id else null end) as ipd
        ,case when t_visit.visit_first_visit = '1'  then count(distinct t_visit.t_patient_id)
              when t_visit.visit_first_visit = '0'  then count(distinct t_visit.t_patient_id) else NULL end as รวม

from
    t_patient
    inner join t_visit on t_patient.t_patient_id = t_visit.t_patient_id   
where
    t_visit.f_visit_status_id <> '4'
   and substring(t_visit.visit_financial_discharge_time,1,10) Between '2554-03-01' and '2554-05-01'--substring(?,1,10) AND substring(?,1,10)
group by
  t_visit.visit_first_visit
,t_visit.f_visit_type_id
) as q1
GROUP BY q1.visit



อย่าลืมเปลี่ยนรหัสอำเภอเป็นของตัวเองนะคะ (ตรงที่ ไฮไลท์สีแดงค่ะ)
,count(distinct case when t_patient.patient_amphur = '601100' and t_visit.f_visit_type_id = '0' then t_visit.t_patient_id else null end) as opd_in_cup
,count(distinct case when t_patient.patient_amphur <> '601100' and t_visit.f_visit_type_id = '0' then t_visit.t_patient_id else null end) as opd_out_cup
,count(distinct case when t_patient.patient_amphur = '601100' and t_visit.f_visit_type_id = '1' then t_visit.t_patient_id else null end) as ipd_in_cup
,count(distinct case when t_patient.patient_amphur <> '601100' and t_visit.f_visit_type_id = '1' then t_visit.t_patient_id else null end) as ipd_out_cup
pakee_06
มือวางอันดับ 1
มือวางอันดับ 1
 
โพสต์: 507
ลงทะเบียนเมื่อ: พฤหัสฯ. 01 ม.ค. 1970 7:00 am

Re: รายงานคน ใหม่ เก่า ในปี ในเขตอ.รับผิดชอบ

โพสต์ใหม่โดย pakee_06 » พฤหัสฯ. 30 มิ.ย. 2011 11:46 am

ตัวอย่าง out put ค่ะ

รูปภาพ
pakee_06
มือวางอันดับ 1
มือวางอันดับ 1
 
โพสต์: 507
ลงทะเบียนเมื่อ: พฤหัสฯ. 01 ม.ค. 1970 7:00 am

Re: รายงานคน ใหม่ เก่า ในปี ในเขตอ.รับผิดชอบ

โพสต์ใหม่โดย chumsin » พฤหัสฯ. 07 ก.ค. 2011 10:02 am

ทำใน ireport เลย :biggrin:
แนะนำการโพสรูปด้วยpicasa http://www.hospital-os.com/th/phpbb/viewtopic.php?f=4&t=2776
แก้ไขลายเซ็น กด http://www.hospital-os.com/th/phpbb/ucp.php?i=profile&mode=signature

Mr. Chumsin Sriyan thapae Hospital Satun
Nhso zone 12

Server-IBM.Ram4G
OS -UBUNTU 11.04 64-bit
Hospital-OS Version. -Hos3.9.20bulid01
Postgresql-8.4.x
Backup HP ram2G -Slony-I
ภาพประจำตัวสมาชิก
chumsin
ระดับเทพแห่งเว็บบอร์ด HospitalOS
ระดับเทพแห่งเว็บบอร์ด HospitalOS
 
โพสต์: 1620
ลงทะเบียนเมื่อ: พฤหัสฯ. 01 ม.ค. 1970 7:00 am

Re: รายงานคน ใหม่ เก่า ในปี ในเขตอ.รับผิดชอบ

โพสต์ใหม่โดย pakee_06 » พฤหัสฯ. 07 ก.ค. 2011 11:20 am

ฝากพี่ๆ ช่วยทำนะคะ น้องก้อยเขียนคำสั่งให้แล้ว ^^
pakee_06
มือวางอันดับ 1
มือวางอันดับ 1
 
โพสต์: 507
ลงทะเบียนเมื่อ: พฤหัสฯ. 01 ม.ค. 1970 7:00 am

Re: รายงานคน ใหม่ เก่า ในปี ในเขตอ.รับผิดชอบ

โพสต์ใหม่โดย chumsin » อังคาร 12 ก.ค. 2011 11:19 pm

:cry:
แนะนำการโพสรูปด้วยpicasa http://www.hospital-os.com/th/phpbb/viewtopic.php?f=4&t=2776
แก้ไขลายเซ็น กด http://www.hospital-os.com/th/phpbb/ucp.php?i=profile&mode=signature

Mr. Chumsin Sriyan thapae Hospital Satun
Nhso zone 12

Server-IBM.Ram4G
OS -UBUNTU 11.04 64-bit
Hospital-OS Version. -Hos3.9.20bulid01
Postgresql-8.4.x
Backup HP ram2G -Slony-I
ภาพประจำตัวสมาชิก
chumsin
ระดับเทพแห่งเว็บบอร์ด HospitalOS
ระดับเทพแห่งเว็บบอร์ด HospitalOS
 
โพสต์: 1620
ลงทะเบียนเมื่อ: พฤหัสฯ. 01 ม.ค. 1970 7:00 am

Re: รายงานคน ใหม่ เก่า ในปี ในเขตอ.รับผิดชอบ

โพสต์ใหม่โดย yohan » พฤหัสฯ. 14 ก.ค. 2011 11:41 am

ต้องการอยู่พอดี ขอบคุณมากครับ ^ ^
ภาพประจำตัวสมาชิก
yohan
มือสมัครเล่น
มือสมัครเล่น
 
โพสต์: 93
ลงทะเบียนเมื่อ: พฤหัสฯ. 01 ม.ค. 1970 7:00 am

Re: รายงานคน ใหม่ เก่า ในปี ในเขตอ.รับผิดชอบ

โพสต์ใหม่โดย pakee_06 » จันทร์ 18 ก.ค. 2011 8:59 am

:D :D
pakee_06
มือวางอันดับ 1
มือวางอันดับ 1
 
โพสต์: 507
ลงทะเบียนเมื่อ: พฤหัสฯ. 01 ม.ค. 1970 7:00 am

Re: รายงานคน ใหม่ เก่า ในปี ในเขตอ.รับผิดชอบ

โพสต์ใหม่โดย chumsin » จันทร์ 18 ก.ค. 2011 1:30 pm

เลียนแบบ
แนะนำการโพสรูปด้วยpicasa http://www.hospital-os.com/th/phpbb/viewtopic.php?f=4&t=2776
แก้ไขลายเซ็น กด http://www.hospital-os.com/th/phpbb/ucp.php?i=profile&mode=signature

Mr. Chumsin Sriyan thapae Hospital Satun
Nhso zone 12

Server-IBM.Ram4G
OS -UBUNTU 11.04 64-bit
Hospital-OS Version. -Hos3.9.20bulid01
Postgresql-8.4.x
Backup HP ram2G -Slony-I
ภาพประจำตัวสมาชิก
chumsin
ระดับเทพแห่งเว็บบอร์ด HospitalOS
ระดับเทพแห่งเว็บบอร์ด HospitalOS
 
โพสต์: 1620
ลงทะเบียนเมื่อ: พฤหัสฯ. 01 ม.ค. 1970 7:00 am

Re: รายงานคน ใหม่ เก่า ในปี ในเขตอ.รับผิดชอบ

โพสต์ใหม่โดย chumsin » จันทร์ 18 ก.ค. 2011 1:31 pm

เลียนแบบ
:biggrin:
แนะนำการโพสรูปด้วยpicasa http://www.hospital-os.com/th/phpbb/viewtopic.php?f=4&t=2776
แก้ไขลายเซ็น กด http://www.hospital-os.com/th/phpbb/ucp.php?i=profile&mode=signature

Mr. Chumsin Sriyan thapae Hospital Satun
Nhso zone 12

Server-IBM.Ram4G
OS -UBUNTU 11.04 64-bit
Hospital-OS Version. -Hos3.9.20bulid01
Postgresql-8.4.x
Backup HP ram2G -Slony-I
ภาพประจำตัวสมาชิก
chumsin
ระดับเทพแห่งเว็บบอร์ด HospitalOS
ระดับเทพแห่งเว็บบอร์ด HospitalOS
 
โพสต์: 1620
ลงทะเบียนเมื่อ: พฤหัสฯ. 01 ม.ค. 1970 7:00 am

Re: รายงานคน ใหม่ เก่า ในปี ในเขตอ.รับผิดชอบ

โพสต์ใหม่โดย pakee_06 » จันทร์ 18 ก.ค. 2011 3:17 pm

55555+ :lol: :lol:
pakee_06
มือวางอันดับ 1
มือวางอันดับ 1
 
โพสต์: 507
ลงทะเบียนเมื่อ: พฤหัสฯ. 01 ม.ค. 1970 7:00 am


ย้อนกลับไปยัง เรื่องการออกรายงาน

ผู้ใช้งานขณะนี้

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

cron