公式里标点符号的使用

公式里标点符号的使用,如图颜色不对,感觉标点没用对,求大佬帮看下标点符号

image.png

公式里的代码:

IF(count(split($p_cx, ",")) = count(split($p_cx_bz, ",")), sql("DR_NMS_SQL_SERVER","SELECT REPLACE(ZGOAL1,'%','')  as  ZGOAL1 FROM dbo.ZNMS_GOAL WHERE MATKL = 'GZQTL'",1,1),

sql("DR_NMS_SQL_SERVER","select round(sum(rate)/count(matkl),2) as pj FROM

(

select 

MATKL,

ready_all, 

ready_y,

(case when ready_all = 0 THEN 0 ELSE

cast(cast(ready_y  * 1.0 / ready_all as decimal(18,3)) * 100  as decimal(18,1)) END )as rate

from (

SELECT 

MATKL,

COUNT(READY) AS ready_all,

COUNT(case when READY = 'Y' then 1 end) AS ready_y

FROM [dbo].[ZNMS_JIT_H1]

 WHERE Z1STMP1 IN (SELECT  Z1STMP1

     FROM dbo.ZNMS_JIT_H1

    WHERE DATEPART(DW,Z1STMP1)=2 

    GROUP BY Z1STMP1)

    ${if(len(p_cx)==0,"","and matkl in ( '"+p_cx+"' )")}   

    ${if(len(p_dateEditor0)==0,"","and Z1MON >= '"+p_dateEditor0+"'")}   

    ${if(len(p_dateEditor1)==0,"","and Z1MON <= '"+p_dateEditor1+"'")}

group by MATKL

    ) t1

) T0",1,1))

全部的代码,执行报错

image.png

FineReport 狂奔的小蜗牛 发布于 2022-12-26 16:28 (编辑于 2022-12-26 16:36)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共2回答
最佳回答
0
Z4u3z1Lv6专家互助
发布于2022-12-26 16:32

IF(

count(split($p_cx, ",")) = count(split($p_cx_bz, ",")), 

sql("DR_NMS_SQL_SERVER","SELECT REPLACE(ZGOAL1,'%','')  as  ZGOAL1 FROM dbo.ZNMS_GOAL WHERE MATKL = 'GZQTL'",1,1),

sql("DR_NMS_SQL_SERVER","select round(sum(rate)/count(matkl),2) as pj FROM

(

select 

MATKL,

ready_all, 

ready_y,

(case when ready_all = 0 THEN 0 ELSE

cast(cast(ready_y  * 1.0 / ready_all as decimal(18,3)) * 100  as decimal(18,1)) END )as rate

from (

SELECT 

MATKL,

COUNT(READY) AS ready_all,

COUNT(case when READY = 'Y' then 1 end) AS ready_y

FROM [dbo].[ZNMS_JIT_H1]

 WHERE Z1STMP1 IN (SELECT  Z1STMP1

     FROM dbo.ZNMS_JIT_H1

    WHERE DATEPART(DW,Z1STMP1)=2 

    GROUP BY Z1STMP1)

    "+if(len(p_cx)==0,"","and matkl in ( '"+p_cx+"' )")+"

    "+if(len(p_dateEditor0)==0,"","and Z1MON >= '"+p_dateEditor0+"'")+"

    "+if(len(p_dateEditor1)==0,"","and Z1MON <= '"+p_dateEditor1+"'")+"

group by MATKL

    ) t1

) T0",1,1))

  • 狂奔的小蜗牛 狂奔的小蜗牛(提问者) 是把where下整个if当成一个变量了,用双引号包起来了,但是不用单引号在双引号外层在包一下吗
    2022-12-26 16:42 
最佳回答
0
用户6NWif5139660Lv6资深互助
发布于2022-12-26 16:29(编辑于 2022-12-26 16:30)

这个没问题 因为跑到下一行了所以颜色不变的

你把他们都写到一行 不要用美化的样式

  • 狂奔的小蜗牛 狂奔的小蜗牛(提问者) 放一行执行也不行,看补充报错了。我确实sql是没问题的,我在数据库单独执行了
    2022-12-26 16:37 
  • 用户6NWif5139660 用户6NWif5139660 回复 狂奔的小蜗牛(提问者) 你写公式 就不要用数据集为那种为空查全部的写法了
    2022-12-26 16:43 
  • 狂奔的小蜗牛 狂奔的小蜗牛(提问者) 回复 用户6NWif5139660 啊?咱俩说的是一个事么,我看蒙了呢
    2022-12-26 16:53 
  • 用户6NWif5139660 用户6NWif5139660 回复 狂奔的小蜗牛(提问者) 你sql不是写的为空查全部吗?你放到报表公式就不能这个写了
    2022-12-26 17:02 
  • 2关注人数
  • 236浏览人数
  • 最后回答于:2022-12-26 16:36
    请选择关闭问题的原因
    确定 取消
    返回顶部