SELECT
S.COMPANY_NAME,--公司
S.PROJECT_NAME,--项目
to_char(to_date(S.PRESALEDATE,'yyyymmdd'),'yyyy-mm-dd') kdate,
S.*
FROM (
SELECT
O.COMPANY_NAME,--公司
O.PROJECT_NAME,--项目
to_char(to_date(D.PRESALEDATE,'yyyymmdd'),'yyyy-mm-dd') kdate,
D.*
FROM "DM"."DM_YX13_SELL_DETAILS" D
LEFT JOIN "DM"."DIM_MANAGING_ORG" O ON D.ORG_GUID=O.ORG_GUID
where 1=1
${IF(LEN(p1)==0,"","AND O.COMPANY_NAME='"+p1+"'")}
${IF(LEN(p2)==0,"","AND O.PROJECT_NAME='"+p2+"'")}
${IF(LEN(p3)==0,"","AND D.STAGE_NAME='"+p3+"'")}
${IF(LEN(p4)==0,"","AND D.SIGN_SUBSC_NAME='"+p4+"'")}
) S
where 1=1
${IF(LEN(p1)==0,"","AND S.COMPANY_NAME='"+p1+"'")}
${IF(LEN(p2)==0,"","AND S.PROJECT_NAME='"+p2+"'")}
${IF(LEN(p3)==0,"","AND S.STAGE_NAME='"+p3+"'")}
${IF(LEN(p4)==0,"","AND S.SIGN_SUBSC_NAME='"+p4+"'")}
${IF(LEN(k)==0,"","AND kdate>='"+k+"'")}
${IF(LEN(e)==0,"","AND kdate<='"+e+"'")
是我自己sql写错了,外面多写了一个左连接,丢人了。。
谢谢大家的帮助~