my.ini conifg
[mysqld]
skip-locking
skip-innodb
query_cache_limit=1M
query_cache_size=32M
query_cache_type=1
max_connections=500
interactive_timeout=100
wait_timeout=100
connect_timeout=10
thread_cache_size=128
key_buffer=16M
join_buffer=1M
max_allowed_packet=16M
table_cache=1024
record_buffer=1M
sort_buffer_size=2M
read_buffer_size=2M
max_connect_errors=10
# Try number of CPU’s*2 for thread_concurrency
thread_concurrency=2
myisam_sort_buffer_size=64M
log-bin
server-id=1
[safe_mysqld]
err-log=/var/log/mysqld.log
open_files_limit=8192
[mysqldump]
quick
max_allowed_packet=16M
[mysql]
no-auto-rehash
#safe-updates
[isamchk]
key_buffer=64M
sort_buffer=64M
read_buffer=16M
write_buffer=16M
[myisamchk]
key_buffer=64M
sort_buffer=64M
read_buffer=16M
write_buffer=16M
[mysqlhotcopy]
interactive-timeout
ที่มา : http://www.idatabase.in.th/2008/11/23/optimize-mysql
บริการทันตกรรม แยกผู้รับบริการ
select m.doctor,d.name,t.code,t.name,m.vn,m.hn,count(m.vn) as vn_count ,sum(m.tcount) as t_count , sum(m.scount) as s_count
from dttm t
left outer join dtmain m on m.tmcode=t.code and m.vstdate between ‘2015-10-01’ and ‘2015-10-01’
left join doctor d on d.code=m.doctor
group by m.doctor,m.vn,m.hn,t.code,t.name
สรุปข้อมูลการบริการแยกรายแผนก เช้า – บ่าย – ดึก – รวม คำนวณตามวันรับบริการ
select o.send_to_depcode as ‘รหัสหน่วยงาน’,k.department as ‘หน่วยงาน’,
count(case when ov.vsttime between ’08:00′ and ’16:00′ then 1 end )as ‘เวรเช้า’,
count(case when ov.vsttime between ’08:00′ and ’16:00′ then 1 end )/
count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate)))) as ‘เฉลี่ยเช้า’,
sum(case when ov.vsttime between ’08:00′ and ’16:00′ then round(v.income,2) end)as ‘ค่าใช้จ่ายเช้า’,
count(case when ov.vsttime between ’16:01′ and ’23:59′ then 1 end)as ‘เวรบ่าย’,
count(case when ov.vsttime between ’16:01′ and ’23:59′ then 1 end)/
count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate)))) as ‘เฉลี่ยเวรบ่าย’,
sum(case when ov.vsttime between ’16:01′ and ’23:59′ then round(v.income,2) end)as ‘ค่าใช้จ่ายบ่าย’,
count(case when ov.vsttime between ’00:01′ and ’08:00′ then 1 end)as ‘เวรดึก’,
count(case when ov.vsttime between ’00:01′ and ’08:00′ then 1 end)/
count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate)))) as ‘เฉลี่ยดึก’,
sum(case when ov.vsttime between ’00:01′ and ’08:00′ then round(v.income,2) else 0 end)as ‘ค่าใช้จ่ายดึก’,
count(*) as ‘รวมครั้งทั้งหมด’,
count(*)/count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))as ‘เฉลี่ยทั้งหมด’,
sum(round(v.income,2))as ‘ค่าใช้จ่ายรวม’,
(case when o.send_to_depcode=001 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=002 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=003 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=005 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=010 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=011 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=017 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=026 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=028 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=029 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=031 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=034 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=035 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=041 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=042 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=043 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=044 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=045 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=049 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=054 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=051 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=052 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=056 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
when o.send_to_depcode=077 then count(distinct(concat(day(v.vstdate),month(v.vstdate),year(v.vstdate))))
end)as ‘วัน/เดือน’
from opd_regist_sendlist o
left join vn_stat v on v.vn=o.vn
left join ovst ov on ov.vn=v.vn
left join kskdepartment k on k.depcode=o.send_to_depcode
where (v.vstdate between ‘2015-11-01 00:00:00’ and ‘2015-11-31 23:59:59’)
and o.send_to_depcode not in (‘009′,’007′,’012′,’037′,’038′,’025′,’061′,’064′,’013′,’014′,’015′,’016′,’019′,’020′,’021′,’027′,’030′,’032′,’036′,’046′,’047′,’039’,
‘048’,’050′,’055′,’063′,’999′,’066′,’008′)
group by o.send_to_depcode
order by o.send_to_depcode
แก้ปริ้นห้องยา ใบสั่งยาค้าง จากห้องตรวจ 2 ปรับ N ให้เป็น Y
select * from printserver_document where print_from_computer =’DR002′ and print_ok=’N’
ตั้งค่า hosxp ปีใหม่ (i_refer_number+o_refer_number)
select * from serial
where name like “HN”
or name like “AN”
or name like “%refer_num%”
or name like “%xn-%”
or name like “%dn-%”
order by serial.name
/* refer in-out Reset นับใหม่ทุกปี */
ความเห็นล่าสุด