60, (cad_coop.cad_center2_ags_member.0102000101 + cad_coop.cad_center2_ags_member.0102000102 + cad_coop.cad_center2_ags_member.0102000201 + cad_coop.cad_center2_ags_member.0102000202 - (cad_coop.cad_center2_ags_member.0102000301 + cad_coop.cad_center2_ags_member.0102000302)) , (cad_coop.cad_center2_eco_member.0102000101 + cad_coop.cad_center2_eco_member.0102000102 + cad_coop.cad_center2_eco_member.0102000201 + cad_coop.cad_center2_eco_member.0102000202 - (cad_coop.cad_center2_eco_member.0102000301 + cad_coop.cad_center2_eco_member.0102000302)) ) DESC "; $orderName="สมาชิก"; break; case 6: $orderBy=" ORDER BY if(cad_coop.coop_name.coop_type_id<>60,(cad_coop.cad_center2_ags_balance.a4800004401),(cad_coop.cad_center2_balancesheet.e2700003601) ) DESC "; $orderName="ทุนดำเนินงาน"; break; case 7: $orderName="ปริมาณธุรกิจ"; $orderBy=" ORDER BY if(cad_coop.coop_name.coop_type_id<>60, ( ( (cad_center2_ags_deposit.0301010201) + (cad_center2_ags_deposit.0301010202) + (cad_center2_ags_deposit.0301010203) + (cad_center2_ags_deposit.0301020201) + (cad_center2_ags_deposit.0301020202) + (cad_center2_ags_deposit.0301020203) + (cad_center2_ags_deposit.0301030201) + (cad_center2_ags_deposit.0301030202) + (cad_center2_ags_deposit.0301030203) ) + ((cad_center2_ags_loan.a0302010201)+(cad_center2_ags_loan.a0302010202)+(cad_center2_ags_loan.a0302010203)+ (cad_center2_ags_oloan.a0302020201)+(cad_center2_ags_oloan.a0302020202)+(cad_center2_ags_oloan.a0302020203)) + (cad_center2_ags_profitproduct.a0802001501) + (cad_center2_ags_product.a0400005201) + (cad_center2_ags_profitlostdetail.1600000401) + (cad_center2_ags_profitsupportland.a1200001101) ) , ( ( (cad_center2_eco_deposit.0301010201) + (cad_center2_eco_deposit.0301010202) + (cad_center2_eco_deposit.0301010203) + (cad_center2_eco_deposit.0301020201) + (cad_center2_eco_deposit.0301020202) + (cad_center2_eco_deposit.0301020203) + (cad_center2_eco_deposit.0301030201) + (cad_center2_eco_deposit.0301030202) + (cad_center2_eco_deposit.0301030203) ) + ((cad_center2_eco_loan.0302010201)+(cad_center2_eco_loan.0302010202)+(cad_center2_eco_loan.0302010203)+ (cad_center2_eco_oloan.0302020201)+(cad_center2_eco_oloan.0302020202)) + ( (cad_center2_eco_prosale.0303010101)+(cad_center2_eco_prosale.0303010201)+ (cad_center2_eco_prosale.0303010301)+(cad_center2_eco_prosale.0303010401)+ (cad_center2_eco_prosale.0303010501)+(cad_center2_eco_prosale.0303020101)+ (cad_center2_eco_prosale.0303020201)+(cad_center2_eco_prosale.0303020301)+ (cad_center2_eco_prosale.0303020401)+(cad_center2_eco_prosale.0303020501)+ (cad_center2_eco_prosale.0303020601)+(cad_center2_eco_prosale.0303020701)+ (cad_center2_eco_prosale.0303020801)+(cad_center2_eco_prosale.0303020901)+ (cad_center2_eco_prosale.0303021001)+(cad_center2_eco_prosale.0303030101)+ (cad_center2_eco_prosale.0303030201)+(cad_center2_eco_prosale.0303030301)+ (cad_center2_eco_prosale.0303030401)+(cad_center2_eco_prosale.0303030501) ) ) ) DESC "; break; } $sql=" SELECT cad_coop.coop_acc_office.coop_acc_office_short_name AS 'สตท.', cad_coop.province.province_name AS 'สตส.', cad_coop.coop_name.coop_id AS 'รหัส', cad_coop.coop_name.coop_name AS 'ชื่อสหกรณ์', cad_center2_import.acc_year AS 'ปีบัญชี', if(cad_coop.coop_name.coop_type_id<>60, (cad_coop.cad_center2_ags_member.0102000101 + cad_coop.cad_center2_ags_member.0102000102 + cad_coop.cad_center2_ags_member.0102000201 + cad_coop.cad_center2_ags_member.0102000202 - (cad_coop.cad_center2_ags_member.0102000301 + cad_coop.cad_center2_ags_member.0102000302)) , (cad_coop.cad_center2_eco_member.0102000101 + cad_coop.cad_center2_eco_member.0102000102 + cad_coop.cad_center2_eco_member.0102000201 + cad_coop.cad_center2_eco_member.0102000202 - (cad_coop.cad_center2_eco_member.0102000301 + cad_coop.cad_center2_eco_member.0102000302)) ) AS 'สมาชิก' , if(cad_coop.coop_name.coop_type_id<>60,(cad_coop.cad_center2_ags_balance.a4800004401),(cad_coop.cad_center2_balancesheet.e2700003601) ) AS 'ทุนดำเนินงาน' , if(cad_coop.coop_name.coop_type_id<>60, ( ( (cad_center2_ags_deposit.0301010201) + (cad_center2_ags_deposit.0301010202) + (cad_center2_ags_deposit.0301010203) + (cad_center2_ags_deposit.0301020201) + (cad_center2_ags_deposit.0301020202) + (cad_center2_ags_deposit.0301020203) + (cad_center2_ags_deposit.0301030201) + (cad_center2_ags_deposit.0301030202) + (cad_center2_ags_deposit.0301030203) ) + ((cad_center2_ags_loan.a0302010201)+(cad_center2_ags_loan.a0302010202)+(cad_center2_ags_loan.a0302010203)+ (cad_center2_ags_oloan.a0302020201)+(cad_center2_ags_oloan.a0302020202)+(cad_center2_ags_oloan.a0302020203)) + (cad_center2_ags_profitproduct.a0802001501) + (cad_center2_ags_product.a0400005201) + (cad_center2_ags_profitlostdetail.1600000401) + (cad_center2_ags_profitsupportland.a1200001101) ) , ( ( (cad_center2_eco_deposit.0301010201) + (cad_center2_eco_deposit.0301010202) + (cad_center2_eco_deposit.0301010203) + (cad_center2_eco_deposit.0301020201) + (cad_center2_eco_deposit.0301020202) + (cad_center2_eco_deposit.0301020203) + (cad_center2_eco_deposit.0301030201) + (cad_center2_eco_deposit.0301030202) + (cad_center2_eco_deposit.0301030203) ) + ((cad_center2_eco_loan.0302010201)+(cad_center2_eco_loan.0302010202)+(cad_center2_eco_loan.0302010203)+ (cad_center2_eco_oloan.0302020201)+(cad_center2_eco_oloan.0302020202)) + ( (cad_center2_eco_prosale.0303010101)+(cad_center2_eco_prosale.0303010201)+ (cad_center2_eco_prosale.0303010301)+(cad_center2_eco_prosale.0303010401)+ (cad_center2_eco_prosale.0303010501)+(cad_center2_eco_prosale.0303020101)+ (cad_center2_eco_prosale.0303020201)+(cad_center2_eco_prosale.0303020301)+ (cad_center2_eco_prosale.0303020401)+(cad_center2_eco_prosale.0303020501)+ (cad_center2_eco_prosale.0303020601)+(cad_center2_eco_prosale.0303020701)+ (cad_center2_eco_prosale.0303020801)+(cad_center2_eco_prosale.0303020901)+ (cad_center2_eco_prosale.0303021001)+(cad_center2_eco_prosale.0303030101)+ (cad_center2_eco_prosale.0303030201)+(cad_center2_eco_prosale.0303030301)+ (cad_center2_eco_prosale.0303030401)+(cad_center2_eco_prosale.0303030501) ) ) ) AS 'ปริมาณธุรกิจ'FROM cad_coop.coop_name Left Join cad_coop.province ON cad_coop.coop_name.province_id = cad_coop.province.province_id LEFT Join cad_coop.coop_acc_office ON cad_coop.province.coop_acc_office_id = cad_coop.coop_acc_office.coop_acc_office_id LEFT Join cad_coop.cad_center2_import ON cad_coop.cad_center2_import.coop_id = cad_coop.coop_name.coop_id LEFT Join cad_coop.cad_center2_ags_member ON cad_coop.cad_center2_import.coop_code_ref = cad_coop.cad_center2_ags_member.coop_code_ref LEFT Join cad_coop.cad_center2_ags_balance ON cad_coop.cad_center2_import.coop_code_ref = cad_coop.cad_center2_ags_balance.coop_code_ref LEFT Join cad_coop.cad_center2_ags_deposit ON cad_coop.cad_center2_import.coop_code_ref = cad_coop.cad_center2_ags_deposit.coop_code_ref LEFT Join cad_coop.cad_center2_ags_loan ON cad_coop.cad_center2_import.coop_code_ref = cad_coop.cad_center2_ags_loan.coop_code_ref LEFT Join cad_coop.cad_center2_ags_oloan ON cad_coop.cad_center2_import.coop_code_ref = cad_coop.cad_center2_ags_oloan.coop_code_ref LEFT Join cad_coop.cad_center2_ags_profitproduct ON cad_coop.cad_center2_import.coop_code_ref = cad_coop.cad_center2_ags_profitproduct.coop_code_ref LEFT Join cad_coop.cad_center2_ags_profitlostdetail ON cad_coop.cad_center2_import.coop_code_ref = cad_coop.cad_center2_ags_profitlostdetail.coop_code_ref LEFT Join cad_coop.cad_center2_ags_product ON cad_coop.cad_center2_import.coop_code_ref = cad_coop.cad_center2_ags_product.coop_code_ref LEFT Join cad_coop.cad_center2_ags_profitsupportland ON cad_coop.cad_center2_import.coop_code_ref = cad_coop.cad_center2_ags_profitsupportland.coop_code_ref LEFT Join cad_coop.cad_center2_eco_member ON cad_coop.cad_center2_import.coop_code_ref = cad_coop.cad_center2_eco_member.coop_code_ref LEFT Join cad_coop.cad_center2_balancesheet ON cad_coop.cad_center2_import.coop_code_ref = cad_coop.cad_center2_balancesheet.coop_code_ref LEFT Join cad_coop.cad_center2_eco_deposit ON cad_coop.cad_center2_import.coop_code_ref = cad_coop.cad_center2_eco_deposit.coop_code_ref LEFT Join cad_coop.cad_center2_eco_loan ON cad_coop.cad_center2_import.coop_code_ref = cad_coop.cad_center2_eco_loan.coop_code_ref LEFT Join cad_coop.cad_center2_eco_oloan ON cad_coop.cad_center2_import.coop_code_ref = cad_coop.cad_center2_eco_oloan.coop_code_ref LEFT Join cad_coop.cad_center2_eco_prosale ON cad_coop.cad_center2_import.coop_code_ref = cad_coop.cad_center2_eco_prosale.coop_code_ref LEFT Join cad_coop.cad_center2_eco_profitlose ON cad_coop.cad_center2_import.coop_code_ref = cad_coop.cad_center2_eco_profitlose.coop_code_ref WHERE cad_coop.coop_name.coop_type_id IN ('".$cooptypeQ."') ".$accofficeQ." AND ( cad_coop.cad_center2_import.acc_year = (select Max(cad_coop.cad_center2_import.acc_year) FROM cad_coop.cad_center2_import where cad_coop.cad_center2_import.coop_id= cad_coop.coop_name.coop_id GROUP BY cad_coop.cad_center2_import.coop_id) ) AND cad_coop.coop_name.status_id<=2 ".$orderBy." LIMIT 100"; //echo $sql; $rs =mysql_query($sql); $num = mysql_num_rows($rs); $num_f= mysql_num_fields($rs); ?> >".number_format($r[$c]).""; }else if ($c>5){ echo ""; }elseif($c==4){ echo ""; }else{ echo ""; } } ?>
> | ทั้งประเทศ | สตท.1 | สตท.2 | สตท.3 | สตท.4 | สตท.5 | สตท.6 | สตท.7 | สตท.8 | สตท.9 | สตท.10 |
> | การเกษตร | ประมง | นิคม | ร้านค้า | บริการ | เครดิตยูเนี่ยน | ออมทรัพย์ | กลุ่มเกษตรกร | รวมสหกรณ์ | รวม |
>TOP 100
>
ที่ =5){?>
".number_format($r[$c],2)."".chg_date_th($r[$c])."".$r[$c]."