这个数据集应该怎样写?报错TMMP

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_AREA

FROM MDM_TIME MT

LEFT JOIN WR_ET_QUALITY_HOLE WEH ON MT.FYMDAY =  WEH.INVESTIGATION_DATE  

WHERE MT.FYEAR = '${NIAN}' 

)

SELECT

TMP,

TMMP,

SUM(NUM) AS 数量,

MACHINE

FROM INFO

WHERE 1=1

${IF(LEN(MUN)=0,"","AND TMP= '"+MUN+"' ")}

${IF(LEN(QUYU)=0,"","AND HOLE_AREA = '"+QUYU+"'")}

GROUP BY TMP,TMMP,MACHINE

ORDER BY TMP+0

FineReport 帆软用户BgY7D4i1Xh 发布于 2022-8-19 09:53 (编辑于 2022-8-19 09:53)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共1回答
最佳回答
0
CD20160914Lv8专家互助
发布于2022-8-19 09:59

WEIDU  参数没有录入的话。你是空。。没有返回 tmmp字段。。你至少得类似这样

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, ","null as TMMP,")))))} 

WEH.HOLE_QUANTITY AS NUM,

WEH.MACHINE,

WEH.HOLE_AREA

FROM MDM_TIME MT

LEFT JOIN WR_ET_QUALITY_HOLE WEH ON MT.FYMDAY =  WEH.INVESTIGATION_DATE  

WHERE MT.FYEAR = '${NIAN}' 

)

SELECT

TMP,

TMMP,

SUM(NUM) AS 数量,

MACHINE

FROM INFO

WHERE 1=1

${IF(LEN(MUN)=0,"","AND TMP= '"+MUN+"' ")}

${IF(LEN(QUYU)=0,"","AND HOLE_AREA = '"+QUYU+"'")}

GROUP BY TMP,TMMP,MACHINE

ORDER BY TMP+0

  • 2关注人数
  • 244浏览人数
  • 最后回答于:2022-8-19 09:59
    请选择关闭问题的原因
    确定 取消
    返回顶部