sql里面判断传入的这个时间控件的值,怎么判断控件有值的时候,才使用这个条件?

SELECT

CASE WHEN

t1.areaCode THEN

( SELECT sc.areaName FROM s_citycounty sc WHERE sc.areaCode = t1.areaCode ) 

END AS areaName,

t1.countall,

t2.zcall,

t2.anjuan,

t3.lhzctall,

t3.xzchjds,

t3.czjcd,

t1.penalty AS penalty1,

t2.penalty AS penalty2,

t3.penalty AS penalty3 

FROM

(

SELECT

substr( bb.areaCode, 1, 4 ) AS areaCode,

count( bci.id ) AS countall,

sum( bb.penalty ) AS penalty 

FROM

s_project sp

LEFT JOIN bwsn_count_integrity bci ON sp.id = bci.pid

LEFT JOIN bwsn_basicinfo bb ON sp.id = bb.pid 

WHERE

bb.ishistory = 1 

AND bb.historytype = "案件上传" 

AND sp.STATUS = "结案" 

AND DATE_FORMAT(sp.createTime,'%Y-%m-%d') >="${dateEnd_c_c}"

AND DATE_FORMAT(sp.createTime,'%Y-%m-%d') <="${dateStart_c_c}"

AND DATE_FORMAT(sp.endTime,'%Y-%m-%d')>="${dateEnd_c_c_c}"

AND DATE_FORMAT(sp.endTime,'%Y-%m-%d')<="${dateStart_c_c_c}"

GROUP BY

substr( bb.areaCode, 1, 4 ) 

) t1

LEFT JOIN (

SELECT

substr( bb.areaCode, 1, 4 ) AS areaCode,

count( bci.id ) AS zcall,

sum( bci.num & 1 = 1 ) AS anjuan,

sum( bb.penalty ) AS penalty 

FROM

s_project sp

LEFT JOIN bwsn_count_integrity bci ON sp.id = bci.pid

LEFT JOIN bwsn_basicinfo bb ON sp.id = bb.pid 

WHERE

bb.ishistory = 1 

AND bb.historytype = "案件上传" 

AND bb.caseType = "治超" 

AND sp.STATUS = "结案" 

AND DATE_FORMAT(sp.createTime,'%Y-%m-%d') >="${dateEnd_c_c}"

AND DATE_FORMAT(sp.createTime,'%Y-%m-%d') <="${dateStart_c_c}"

AND DATE_FORMAT(sp.endTime,'%Y-%m-%d')>="${dateEnd_c_c_c}"

AND DATE_FORMAT(sp.endTime,'%Y-%m-%d')<="${dateStart_c_c_c}"

GROUP BY

substr( bb.areaCode, 1, 4 ) 

) t2 ON t1.areaCode = t2.areaCode

LEFT JOIN (

SELECT

substr( bb.areaCode, 1, 4 ) AS areaCode,

count( bci.id ) AS lhzctall,

sum( bci.num & 2 = 2 ) AS xzchjds,

sum( bci.num & 4 = 4 ) AS czjcd,

sum( bb.penalty ) AS penalty 

FROM

s_project sp

LEFT JOIN bwsn_count_integrity bci ON sp.id = bci.pid

LEFT JOIN bwsn_basicinfo bb ON sp.id = bb.pid 

WHERE

bb.ishistory = 1 

AND bb.historytype = "案件上传" 

AND bb.caseType = "联合治超" 

AND sp.STATUS = "结案" 

AND DATE_FORMAT(sp.createTime,'%Y-%m-%d') >="${dateEnd_c_c}"

AND DATE_FORMAT(sp.createTime,'%Y-%m-%d') <="${dateStart_c_c}"

AND DATE_FORMAT(sp.endTime,'%Y-%m-%d')>="${dateEnd_c_c_c}"

AND DATE_FORMAT(sp.endTime,'%Y-%m-%d')<="${dateStart_c_c_c}"

GROUP BY

substr( bb.areaCode, 1, 4 ) 

) t3 ON t1.areaCode = t3.areaCode

image.pngimage.png

FineReport sw0414 发布于 2021-5-19 09:36 (编辑于 2021-5-19 09:38)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共2回答
最佳回答
0
xiaomingyiLv6中级互助
发布于2021-5-19 09:38(编辑于 2021-5-19 10:45)

${if(len(dateEnd_c_c)=0,""," AND DATE_FORMAT(sp.createTime,'%Y-%m-%d') >='"+dateEnd_c_c+"' ")}

图片.png

  • sw0414 sw0414(提问者) 报错了
    2021-05-19 10:09 
  • xiaomingyi xiaomingyi 回复 sw0414(提问者) 报什么错?你看我上传的图,我们平时就是这么写的
    2021-05-19 10:46 
最佳回答
0
177741977Lv6初级互助
发布于2021-5-19 09:39

${if(len(传入参数)==0,"","xxx")}

  • 3关注人数
  • 944浏览人数
  • 最后回答于:2021-5-19 10:45
    请选择关闭问题的原因
    确定 取消
    返回顶部