我有一个如下的sql查询,
select Site,DataSource,
(SELECT CASE
WHEN DataSource = 'RFQ' THEN 'ChangeOperator'
ELSE 'SameOperator'
END) AS OperatorScenario,
(SELECT CASE
WHEN OperatorScenario = 'ChangeOperator' THEN '1'
ELSE '022'
END) AS OperatorScenario2
from tablename
当我执行此查询时,我收到异常为 Invalid column name OperatorScenario。所以我尝试在第二个查询中使用别名中的单个代码,如下所示,
(SELECT CASE
WHEN 'OperatorScenario' = 'ChangeOperator' THEN '1'
ELSE '022'
END) AS OperatorScenario2
所以它总是执行 else 部分。请给我一些建议。问候桑吉塔