WITH INFO AS (SELECT${if(WEEK="月","MT.FMONTH AS TMP, ","MT.FWEEK AS TMP, ")} ${if(WEIDU="按班组","WEH.SHIFT AS TMMP, ",IF(WEIDU="按员工","WEH.JOCKEY AS TMMP, ",IF(WEIDU="按产品contype","WEH.PRODUCT_TYPE AS TMMP, ",IF(WEIDU="按检验阶段","WEH.INSPECTION_STAGE AS TMMP, ",IF(WEIDU="按浸渍线","WEH.IMPREGNATION_LINE AS TMMP, ","")))))} WEH.HOLE_QUANTITY AS NUM,WEH.MACHINE,WEH.HOLE_AREAFROM MDM_TIME MTLEFT JOIN WR_ET_QUALITY_HOLE WEH ON MT.FYMDAY = WEH.INVESTIGATION_DATE WHERE MT.FYEAR = '${NIAN}' )SELECTTMP,TMMP,SUM(NUM) AS 数量,MACHINEFROM INFOWHERE 1=1${IF(LEN(MUN)=0,"","AND TMP= '"+MUN+"' ")}${IF(LEN(QUYU)=0,"","AND HOLE_AREA = '"+QUYU+"'")}GROUP BY TMP,TMMP,MACHINEORDER BY TMP+0