SELECT ZXNJG_TXT, KH_TXT,KHFL1_TXT,KHFL2_TXT, XL,SJ_CJJ,MMMBWCS2 FROM (SELECT A.MMMBWCS2,case when ZXNJG_TXT='龙江' then '黑龙江' else ZXNJG_TXT end ZXNJG_TXT,KH_TXT,KHFL1_TXT,KHFL2_TXT,SUM(A.XL) XL, case when SUM(A.XL)=0 then SUM(A.ZJE)/SUM(A.XL)=0 else SUM(A.ZJE)/SUM(A.XL) end SJ_CJJ from (SELECT A.ZXNJG_TXT,A.MMMBWCS2,A.CALDAY,B.KH_TXT,B.KHFL1_TXT,B.KHFL2_TXT,SUM(A.QUANT_B) XL, SUM(A.SUBTOT_1S) ZJE FROM ALL_D05.ERP_AC_YPYC_PFJG_GRAPH_ORC A join all_d05.erp_zcustomer_attr_orc B ON A.customer=B.customer WHERE A.DISTR_CHAN in ("21","22") GROUP BY A.ZXNJG_TXT, A.CALDAY,B.KH_TXT,B.KHFL1_TXT,B.KHFL2_TXT,A.MMMBWCS2 ) A group by ZXNJG_TXT,KH_TXT,KHFL1_TXT,KHFL2_TXT,MMMBWCS2 |
最佳回答 |
||||
0
|
|