I want to create the following line into SQL statement:
我想在SQL语句中创建以下行:
If account code
is XING replace the strategy
to GRE?
如果帐户代码是XING,请将策略替换为GRE?
I have the following which is not working:
我有以下不起作用:
/if($_Account Master.Account Code CNS$,/replace($_Account Master.Strategy$,$_Account Master.Strategy$,GRE))
Please let me know the correct method.
请告诉我正确的方法。
2 个解决方案
#1
3
If you're talking about replacing value in a variable based on variable go with
如果你在谈论基于变量替换变量中的值,请参阅
IF @AcciountCode = 'XING' @Strategy = 'GRE'
But I have a feeling you need to update respective fields in the table. If so, you need something like
但我有一种感觉,你需要更新表中的相应字段。如果是这样,你需要类似的东西
UPDATE [Account Master] SET Strategy = 'GRE' WHERE [Account Code] = 'XING'
#2
2
This is how you do it in a select statement:
这是您在select语句中执行此操作的方式:
SELECT CASE WHEN [Account Code] = 'XING' THEN 'GRE' ELSE [Strategy] END AS [Strategy]
FROM [Account Master]
#1
3
If you're talking about replacing value in a variable based on variable go with
如果你在谈论基于变量替换变量中的值,请参阅
IF @AcciountCode = 'XING' @Strategy = 'GRE'
But I have a feeling you need to update respective fields in the table. If so, you need something like
但我有一种感觉,你需要更新表中的相应字段。如果是这样,你需要类似的东西
UPDATE [Account Master] SET Strategy = 'GRE' WHERE [Account Code] = 'XING'
#2
2
This is how you do it in a select statement:
这是您在select语句中执行此操作的方式:
SELECT CASE WHEN [Account Code] = 'XING' THEN 'GRE' ELSE [Strategy] END AS [Strategy]
FROM [Account Master]