语句如下: select ResultFile as '品种',BatchId as '批号',TestEnv as '测试状态',count(1) as '测试总量' ,count(case when Result=1 then 1 end ) as '合格量' ,convert(decimal(18,4),(count(case when Result=1 then 1 end) / (count(1)+0.0))) as '总良率' ,convert(decimal(18,4),(count(case when IthResult=1 then 1 end) / (count(1)+0.0))) as ' Ith良率' ,convert(decimal(18,4),(count(case when PfResult=1 then 1 end) / (count(1)+0.0))) as ' Pf良率' ,convert(decimal(18,4),(count(case when SEResult=1 then 1 end) / (count(1)+0.0))) as ' SE良率' ,convert(decimal(18,4),(count(case when RsResult=1 then 1 end) / (count(1)+0.0))) as ' Rs良率' ,convert(decimal(18,4),(count(case when VfResult=1 then 1 end) / (count(1)+0.0))) as ' Vf良率' ,0 as 'Im良率',0 as 'Idk判定' ,convert(decimal(18,4),(count(case when KinkResult=1 then 1 end) / (count(1)+0.0))) as ' Kink良率' ,convert(decimal(18,4),(count(case when LostResult=1 then 1 end) / (count(1)+0.0))) as ' SE_Lost良率' ,convert(decimal(18,4),(count(case when bSm0=1 then 1 end) / (count(1)+0.0))) as ' SMSR0良率' ,convert(decimal(18,4),(count(case when bSm1=1 then 1 end) / (count(1)+0.0))) as ' SMSR1良率' ,0 as 'SMSR2良率' ,convert(decimal(18,4),(count(case when bWd=1 then 1 end) / (count(1)+0.0))) as ' WavDiff良率' ,convert(decimal(18,4),(count(case when PbResult=1 then 1 end) / (count(1)+0.0))) as ' Stop_band良率' From CHIP_TEST where 1=1 group by ResultFile,BatchId,TestEnv 参数条件如下: ${if(type=="日报"," and date(TesTime )='"+ date +"'", if(type=="月报"," and strftime('%m',CHIP_TEST.TesTime )='"+ month+"'"+" and strftime('%Y',CHIP_TEST. TesTime )='"+ year+"'"," and strftime('%Y',CHIP_TEST.TesTime )='"+ year+"'"))} 参数不论放 1=1 后面 还是放group by 后面 都报错1=1 后面报 strftime 不存在函数group by 报错 and 错误 |