select count(distinct(if(lo.lab_items_code=231,lh.vn,null))) as "fbs_all"
,count(distinct(if(lo.lab_items_code=231 and lo.lab_order_result >110,lh.vn,null))) as "fbs110up"
,count(distinct(if(lo.lab_items_code=231 and lo.lab_order_result <126,lh.vn,null))) as "FBSLess126"
,count(distinct(if(lo.lab_items_code=231 and lo.lab_order_result >=126,lh.vn,null))) as "FBSMoreOrEqual126"
,count(distinct(if(lo.lab_items_code=316,lh.vn,null))) as "fpgall"
,count(distinct(if(lo.lab_items_code=316 and lo.lab_order_result >110,lh.vn,null))) as "fpg110up"
,count(distinct(if(lo.lab_items_code=316 and lo.lab_order_result<126,lh.vn,null))) as "FPGLess126"
,count(distinct(if(lo.lab_items_code=316 and lo.lab_order_result>=126,lh.vn,null))) as "FPGMoreOrEqual126"
,count(distinct(if(lo.lab_items_code=117,lh.vn,null))) as "chol_all"
,count(distinct(if(lo.lab_items_code=117 and lo.lab_order_result <=200,lh.vn,null))) as "chol_lessequal200"
,count(distinct(if(lo.lab_items_code=118,lh.vn,null))) as "tg_all"
,count(distinct(if(lo.lab_items_code=118 and lo.lab_order_result <=150,lh.vn,null))) as "tg_lessequal150"
,count(distinct(if(lo.lab_items_code=119,lh.vn,null))) as "hdl_all"
,count(distinct(if(lo.lab_items_code=119 and lo.lab_order_result >=40,lh.vn,null))) as "hdl_more40"
,count(distinct(if(lo.lab_items_code=120,lh.vn,null))) as "ldl_all"
,count(distinct(if(lo.lab_items_code=120 and lo.lab_order_result <100,lh.vn,null))) as "ldl_less100"
,count(distinct(if(lo.lab_items_code=99,lh.vn,null))) as "bun_all"
,count(distinct(if(lo.lab_items_code=99 and lo.lab_order_result <=25,lh.vn,null))) as "bun_25"
,count(distinct(if(lo.lab_items_code=100,lh.vn,null))) as "creatinin_all"
,count(distinct(if(lo.lab_items_code=100 and lo.lab_order_result <=1.5,lh.vn,null))) as "creatinin1"
,count(distinct(if(lo.lab_items_code=244,lh.vn,null))) as "UrAl_all"
,count(distinct(if(lo.lab_items_code=244 and lo.lab_order_result="Negative",lh.vn,null))) as "UrAl_Nagative"
,count(distinct(if(lo.lab_items_code=244 and lo.lab_order_result>+1,lh.vn,null))) as "UrAlMore1"
,count(distinct(if(lo.lab_items_code=103,lh.vn,null))) as "Uric_all"
,count(distinct(if(lo.lab_items_code=103 and lo.lab_order_result >7,lh.vn,null))) as "Uric_7up"
,count(distinct(if(lo.lab_items_code=231,lh.hn,null))) as "fbs_allPatient"
,count(distinct(if(lo.lab_items_code=231 and lo.lab_order_result >110,lh.hn,null))) as "fbs110upPatient"
,count(distinct(if(lo.lab_items_code=231 and lo.lab_order_result <126,lh.hn,null))) as "FBSLess126Patient"
,count(distinct(if(lo.lab_items_code=231 and lo.lab_order_result >=126,lh.hn,null))) as "FBSMoreOrEqual126Patient"
,count(distinct(if(lo.lab_items_code=316,lh.hn,null))) as "fpgallPatient"
,count(distinct(if(lo.lab_items_code=316 and lo.lab_order_result >110,lh.hn,null))) as "fpg110upPatient"
,count(distinct(if(lo.lab_items_code=316 and lo.lab_order_result<126,lh.hn,null))) as "FPGLess126Patient"
,count(distinct(if(lo.lab_items_code=316 and lo.lab_order_result>=126,lh.hn,null))) as "FPGMoreOrEqual126Patient"
,count(distinct(if(lo.lab_items_code=117,lh.hn,null))) as "chol_allPatient"
,count(distinct(if(lo.lab_items_code=117 and lo.lab_order_result <=200,lh.hn,null))) as "chol_lessequal200Patient"
,count(distinct(if(lo.lab_items_code=118,lh.hn,null))) as "tg_allPatient"
,count(distinct(if(lo.lab_items_code=118 and lo.lab_order_result <=150,lh.hn,null))) as "tg_lessequal150Patient"
,count(distinct(if(lo.lab_items_code=119,lh.hn,null))) as "hdl_allPatient"
,count(distinct(if(lo.lab_items_code=119 and lo.lab_order_result >=40,lh.hn,null))) as "hdl_more40Patient"
,count(distinct(if(lo.lab_items_code=120,lh.hn,null))) as "ldl_allPatient"
,count(distinct(if(lo.lab_items_code=120 and lo.lab_order_result <100,lh.hn,null))) as "ldl_less100Patient"
,count(distinct(if(lo.lab_items_code=99,lh.hn,null))) as "bun_allPatient"
,count(distinct(if(lo.lab_items_code=99 and lo.lab_order_result <=25,lh.hn,null))) as "bun_25Patient"
,count(distinct(if(lo.lab_items_code=100,lh.hn,0))) as "creatinin_allPatient"
,count(distinct(if(lo.lab_items_code=100 and lo.lab_order_result <=1.5,lh.hn,null))) as "creatinin1Patient"
,count(distinct(if(lo.lab_items_code=244,lh.hn,null))) as "UrAl_allPatient"
,count(distinct(if(lo.lab_items_code=244 and lo.lab_order_result="Negative",lh.hn,null))) as "UrAl_NagativePatient"
,count(distinct(if(lo.lab_items_code=244 and lo.lab_order_result>+1,lh.hn,null))) as "UrAlMore1Patient"
,count(distinct(if(lo.lab_items_code=103,lh.hn,null))) as "Uric_allPatient"
,count(distinct(if(lo.lab_items_code=103 and lo.lab_order_result >7,lh.hn,null))) as "Uric_7upPatient"
from lab_order lo
left outer join lab_head lh on lo.lab_order_number=lh.lab_order_number
left outer join clinicmember c on c.hn=lh.hn
left outer join vn_stat v on v.vn=lh.vn
where v.vstdate between "2011-01-01" and "2011-01-15" and c.clinic="002"
ถ้าตามนี้แล้วมีอะไรผิดกฎการประมวลผลหรือไม่ครับ หรือจะทำให้การประมวลผลมีปัญหา มีผลต่อการเปลี่ยนแปลงค่าใดๆตามมาหรือไม่ครับ