strSql.Append(",case MAX(B.FEESTATUS) when 1 then '锁定' else '未锁定' end as FEESTATUSREF,(select [NAME] from [company] where GID=B.SALECORPID) as SALECORP");
strSql.Append("SUM(G.RMBDR) as RMBDR,SUM(G.RMBCR) AS RMBCR,SUM(G.STLRMBDR) STLRMBDR,SUM(G.STLRMBCR) STLRMBCR,SUM(G.USDDR) AS USDDR,SUM(G.USDCR) AS USDCR,SUM(G.STLUSDDR) STLUSDDR,SUM(G.STLUSDCR) STLUSDCR,SUM(G.OTDR) AS OTDR,SUM(G.OTCR) AS OTCR,SUM(G.STLOTDR) STLOTDR,SUM(G.STLOTCR) STLOTCR,SUM(G.TTLDR) AS TTLDR,SUM(G.TTLCR) AS TTLCR,SUM(G.STLTTLDR) STLTTLDR,SUM(G.STLTTLCR) STLTTLCR");
//else
// strSql.Append("COUNT(DISTINCT B.BSNO) AS BLCOUNT,SUM(G.RMBDR) as RMBDR,SUM(G.RMBCR) AS RMBCR,SUM(G.STLRMBDR) STLRMBDR,SUM(G.STLRMBCR) STLRMBCR,SUM(G.USDDR) AS USDDR,SUM(G.USDCR) AS USDCR,SUM(G.STLUSDDR) STLUSDDR,SUM(G.STLUSDCR) STLUSDCR,SUM(G.OTDR) AS OTDR,SUM(G.OTCR) AS OTCR,SUM(G.STLOTDR) STLOTDR,SUM(G.STLOTCR) STLOTCR,SUM(G.TTLDR) AS TTLDR,SUM(G.TTLCR) AS TTLCR,SUM(G.STLTTLDR) STLTTLDR,SUM(G.STLTTLCR) STLTTLCR");
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.NETWEIGHT ELSE 0 END) AS NETWEIGHT,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) AS TEU,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) AS CNTR1,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) AS CNTR2,");
strSql.Append("SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) AS CNTR3,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) AS CNTR4,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) AS CNTR5,");
strSql.Append("SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) AS CNTR6,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) AS CNTR7,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) AS CNTR8,");
strSql.Append("SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) AS CNTR9,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) AS CNTR10,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) AS OTCNTR");
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.NETWEIGHT ELSE 0 END) AS NETWEIGHT,SUM(B.TEU) AS TEU,SUM(B.CNTR1) AS CNTR1,SUM(B.CNTR2) AS CNTR2,");
strSql.Append("SUM(B.CNTR3) AS CNTR3,SUM(B.CNTR4) AS CNTR4,SUM(B.CNTR5) AS CNTR5,");
strSql.Append("SUM(B.CNTR6) AS CNTR6,SUM(B.CNTR7) AS CNTR7,SUM(B.CNTR8) AS CNTR8,");
strSql.Append("SUM(B.CNTR9) AS CNTR9,SUM(B.CNTR10) AS CNTR10,SUM(B.OTCNTR) AS OTCNTR");
strSql.Append(",SUM(ISNULL(G.USDDR-G.USDCR,0)) AS USDPROFIT,SUM(ISNULL(G.RMBDR-G.RMBCR,0)) AS RMBPROFIT,SUM(ISNULL(G.OTDR-G.OTCR,0)) AS OTPROFIT,SUM(ISNULL(G.TTLDR-G.TTLCR,0)) AS TTLPROFIT ");
strSql.Append(",SUM(ISNULL(G.RMBDR-G.STLRMBDR,0)) AS RMBNODR,SUM(ISNULL(G.USDDR-G.STLUSDDR,0)) AS USDNODR,SUM(ISNULL(G.OTDR-G.STLOTDR,0)) AS OTNODR,SUM(ISNULL(G.TTLDR-G.STLTTLDR,0)) AS TTLNODR");
strSql.Append(",SUM(ISNULL(G.RMBCR-G.STLRMBCR,0)) AS RMBNOCR,SUM(ISNULL(G.USDCR-G.STLUSDCR,0)) AS USDNOCR,SUM(ISNULL(G.OTCR-G.STLOTCR,0)) AS OTNOCR,SUM(ISNULL(G.TTLCR-G.STLTTLCR,0)) AS TTLNOCR");