这样的写法有什么问题

SELECT

PROJECT_NAME AS 项目,

IF(LEN(PROJECT)==0,PROJECT_TYPE,YEAR_MONTHS) AS  分类,

NET_PROFIT_ACT AS 动态版净利润,

NET_PROFIT_TAR AS 方案版净利润,

NET_PROFIT_DEVIATION AS 净利润偏差,

NET_INTEREST_RATE_ACT AS 动态版净利率,

NET_INTEREST_RATE_TAR AS 方案版净利率,

NET_INTEREST_RATE_DEVIATION AS 净利率偏差,

CARGO_VALUE_ACT AS 动态版货值,

CARGO_VALUE_TAR AS 方案版货值,

CARGO_VALUE_DEVIATION AS 货值偏差,

CARGO_COST_ACT AS 动态版成本,

CARGO_COST_TAR AS 方案版成本,

CARGO_COST_DEVIATION AS 成本偏差

FROM 

IF(LEN(PROJECT)==0,DW_LR_FINANCE_INDEX_BY_PRO,DW_LR_FINANCE_INDEX_BY_PRO_MONTH)

WHERE 

IF(AND(LEN(PROJECT)==0,TYPE!='全部项目') ,PROJECT_TYPE = '${TYPE}',PROJECT_NAME = '${PROJECT}')

IF(AND(LEN(PROJECT)==0,TYPE='全部项目') ,,PROJECT_NAME = '${PROJECT}')

SQL 难过的过 发布于 2022-11-7 18:06
1min目标场景问卷 立即参与
回答问题
悬赏:0 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共2回答
最佳回答
0
luojian0323Lv7资深互助
发布于2022-11-7 18:10
最佳回答
0
linbodingLv6中级互助
发布于2022-11-7 18:10(编辑于 2022-11-7 18:22)

if函数要写在${}里,这是帆软的函数

image.png

具体参考https://help.fanruan.com/finereport/doc-view-2395.html

  • 难过的过 难过的过(提问者) where后面的是条件也那写吗??
    2022-11-07 18:16 
  • linboding linboding 回复 难过的过(提问者) 是的
    2022-11-07 18:21 
  • 难过的过 难过的过(提问者) 回复 linboding 可以帮忙写一下吗,我不太理解 SELECT PROJECT_NAME AS 项目, IF(LEN(PROJECT)==0,PROJECT_TYPE,YEAR_MONTHS) AS 分类, NET_PROFIT_ACT AS 动态版净利润, NET_PROFIT_TAR AS 方案版净利润, NET_PROFIT_DEVIATION AS 净利润偏差, NET_INTEREST_RATE_ACT AS 动态版净利率, NET_INTEREST_RATE_TAR AS 方案版净利率, NET_INTEREST_RATE_DEVIATION AS 净利率偏差, CARGO_VALUE_ACT AS 动态版货值, CARGO_VALUE_TAR AS 方案版货值, CARGO_VALUE_DEVIATION AS 货值偏差, CARGO_COST_ACT AS 动态版成本, CARGO_COST_TAR AS 方案版成本, CARGO_COST_DEVIATION AS 成本偏差 FROM IF(LEN(PROJECT)==0,DW_LR_FINANCE_INDEX_BY_PRO,DW_LR_FINANCE_INDEX_BY_PRO_MONTH) ${IF(LEN(PROJECT)==0 AND TYPE !=\'全部项目\' ,WHERE PROJECT_TYPE = \'\"+TYPE+\"\',WHERE PROJECT_NAME = \'\"+PROJECT+\"\')} ${IF(LEN(PROJECT)==0 AND TYPE =\'全部项目\' ,WHERE PROJECT_NAME = \'\"+PROJECT+\"\')} 这样还是不行
    2022-11-07 18:23 
  • 3关注人数
  • 363浏览人数
  • 最后回答于:2022-11-7 18:22
    请选择关闭问题的原因
    确定 取消
    返回顶部