SELECT ${sel_str} FROM (SELECT * FROM "_SYS_BIC"."CB.AL.YW/ZAL_SALES_DETAIL_MAIN" WHERE 1=1 AND ZICZS0000 IN (${GET_ZICZS0000}) AND ZICZS0000 NOT LIKE 'DC%' ) D LEFT JOIN (SELECT A.*,(CASE WHEN G.ZICYY0313 IS NOT NULL THEN G.ZICYY0313 ELSE '30' END ) ZICYY0313, (CASE WHEN G.ZICYY3030 IS NOT NULL THEN G.ZICYY3030 WHEN G.ZICYY3030 IS NULL THEN 'KW' || SUBSTR(A.ZICZS0000,3,6) WHEN G.ZICYY3030 IS NULL AND A.ZICZS0000='8101' THEN 'KW10' WHEN G.ZICYY3030 IS NULL AND A.ZICZS0000='8110' THEN 'KW01' END ) ZICYY3030 FROM "_SYS_BIC"."CB.AL.YW/ZAL_STOCK_BQPRICEJGFDS" (PLACEHOLDER."$$ZIP_STDATE$$"=>${user_date_from} --查询开始日期 ,PLACEHOLDER."$$ZIP_ENDDATE$$"=>${user_date_to}) A LEFT JOIN "_SYS_BIC"."CB.AL.YW/ZAL_STOCK_BQPRICEJGFDS_KWBS" (PLACEHOLDER."$$ZIP_STDATE$$"=>${user_date_from} --查询开始日期 ,PLACEHOLDER."$$ZIP_ENDDATE$$"=>${user_date_to}) G -- 当前日期 ON A.ZICZS0000=G.ZICZS0000 AND A.ZICZB0000=G.ZICZB0000 AND A.ZICZS0000=D.ZICZS0000 AND A.ZICZB0000=D.ZICZB0000 WHERE A.ZICZS0000<>'DC80' AND A.ZICZS0000<>'DC70') A LEFT JOIN "_SYS_BIC"."CB.BL.YW/ZBL_ZDEMM012" B ON A.ZICZS0000=B.ZICZS0000 AND A.ZICZB0000=B.ZICZB0000 LEFT JOIN (SELECT COMP_CODE,ZICZB0000,ZICZA0000,ZICKA0012 AS GSRKRQ FROM "_SYS_BIC"."CB.BL.YW/ZBL_ZDEMM013" ) C ON A.COMP_CODE=C.COMP_CODE AND A.ZICZB0000=C.ZICZB0000 AND A.ZICZA0000=C.ZICZA0000 ${GET_ZICZS0008} ${if(OR(len(SEL_CALDAY_FROM) == 0,len(SEL_CALDAY_TO) == 0),"and and D.CALDAY = '0000000'", "and D.CALDAY >= '" + SEL_CALDAY_FROM + "'" + "and D.CALDAY ${if(len(ZIFXAV001_TO) == 0,"","and D.ZIFXAV001 ${if(len(ZICZB0058_TO) == 0,"","and D.ZICZB0058 ${if(len(ZIFXAW023_TO) == 0,"","and D.ZIFXAW023 <= '" + ZIFXAW023_TO + "'")} --销售克重ZIFXAW023 ${SEL_ZICZB0069} --证书4 ORDER BY ${sel_str} |