SELECT (sum(buliangshu)/sum(tourushu))*100 AS bm_defect_after FROM `bm_basic_data` where 1=1 ${if(len(starttime)=0,""," and times>='"+starttime+"'")}${if(len(endtime)=0,""," and times<='"+endtime+"'")} and bm_model=${bm_model}
SELECT (sum(buliangshu)/sum(tourushu))*100 AS bm_defect_after
FROM `bm_basic_data`
where 1=1
${if(len(starttime)=0,""," and times>='"+starttime+"'")}
${if(len(endtime)=0,""," and times<='"+endtime+"'")}
and bm_model='${bm_model}'
a475547619(提问者)我之前这样是可以的
SELECT *
FROM `bm_basic_data`
where 1=1
${if(len(starttime)=0,\"\",\" and times>=\'\"+starttime+\"\'\")}
${if(len(endtime)=0,\"\",\" and times<=\'\"+endtime+\"\'\")}
and bm_model=\'${bm_model}\'