在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 = "结案" 

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

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

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

if(len(dateEnd_c_c_c)=0,"",AND DATE_FORMAT(sp.createTime,'%Y-%m-%d') >="${dateEnd_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 = "结案" 

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

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

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

if(len(dateEnd_c_c_c)=0,"",AND DATE_FORMAT(sp.createTime,'%Y-%m-%d') >="${dateEnd_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 = "结案" 

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

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

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

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

GROUP BY

substr( bb.areaCode, 1, 4 ) 

) t3 ON t1.areaCode = t3.areaCode

image.pngimage.pngimage.png

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

改成这样

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

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

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

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

  • sw0414 sw0414(提问者) 严重:15:28:36 SocketListener0-5 ERROR [root] 报表计算中[Name : 治超案件上传统计表.cpt] [Parameter : {__FIT__ : true[java.lang.Boolean], __LOCALE__ : zh_CN[java.util.Locale], __STREAMCLOSED__ : [java.lang.String], CHECKBOX0 : false[java.lang.Boolean], CMD : parameters_d[java.lang.String], DATEEND_C_C : 2021-04-29[java.lang.String], DATEEND_C_C_C : [java.lang.String], DATESTART_C_C : 2021-05-19[java.lang.String], DATESTART_C_C_C : [java.lang.String], LABEL0_C_C_C_C : 至[java.lang.String], LABEL0_C_C_C_C_C : 上传日期[java.lang.String], LABEL0_C_C_C_C_C_C : 结案日期[java.lang.String], LABEL0_C_C_C_C_C_C_C : 至[java.lang.String], OP : fr_dialog[java.lang.String], REPORTLET : 治超案件上传统计表.cpt[java.lang.String], REPORTNAME : 治超案件上传统计表.cpt[java.lang.String], SESSIONID : 9286[java.lang.String]}][Type : page] : no function found: f
    2021-05-21 15:29 
  • sw0414 sw0414(提问者) 为啥还报错
    2021-05-21 15:29 
最佳回答
0
snrtuemcLv8专家互助
发布于2021-5-21 15:17

这个错了,是这个格式

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

image.png

最佳回答
0
张洪威Lv6高级互助
发布于2021-5-21 15:45

f(x)写方程吗。

image.png

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