以下查询给出错误 '不喜欢的情况'(第15行,第15行,第1行,第14行 关键字“LIKE”附近的语法不正确
SELECT
TimeStamp,
TimeStampNS,
ISNULL(TagName, 'NoTag') AS TagName,
Message,
ConditionName,
ISNULL(TagName, 'NoTag') + '.' + ConditionName AS Source,
CENTUMMsgId,
StationName,
ISNULL(AlarmLevel,5) AS AlarmLevel,
ActiveTime,
ActorID,
ISNULL(AlarmOff,0) AS AlarmOff,
CASE WHEN NOT LIKE '% ACK%' AND CENTUMMsgId IN (4353, 4355, 4609) THEN 1 ELSE 0 END AS RaiseAll,
CASE WHEN LIKE '% ACK%' THEN 1 ELSE 0 END AS Acknowledge,
CASE WHEN CENTUMMsgId IN (4354, 4356, 4358, 4614) AND Message NOT LIKE '% ACK%' THEN 1 ELSE 0 END AS Normal,
PlantHierarchy,
'EXAOPC' AS SourceType
FROM QHistorianData.dbo.vEXAOPCCSProcessAlarm
你们知道发生了什么......我想我在那里有正确的意思。
提前感谢您的帮助。
答案 0 :(得分:3)
我认为你错过了这里的属性名称:
CASE WHEN <ATTRIBUTE-NAME> NOT LIKE '% ACK%' AND CENTUMMsgId IN (4353, 4355, 4609) THEN 1 ELSE 0 END AS RaiseAll,
CASE WHEN <ATTRIBUTE-NAME> LIKE '% ACK%' THEN 1 ELSE 0 END AS Acknowledge,
CASE WHEN CENTUMMsgId ...
答案 1 :(得分:1)
CASE WHEN **[MissingExpression]** NOT LIKE '% ACK%' AND CENTUMMsgId IN (4353, 4355, 4609) THEN 1 ELSE 0 END AS RaiseAll,
CASE WHEN **[MissingExpression]** LIKE '% ACK%' THEN 1 ELSE 0 END AS Acknowledge,
CASE WHEN CENTUMMsgId IN (4354, 4356, 4358, 4614) AND Message NOT LIKE '% ACK%' THEN 1
ELSE 0 END AS Normal,
PlantHierarchy,
您错过了将要比较的列定义为
答案 2 :(得分:1)
您在WHEN
之后缺少列名称/表达式。
CASE WHEN 'EXPRESSION' NOT LIKE '% ACK%'
AND CENTUMMsgId IN (4353, 4355, 4609)
THEN 1 ELSE 0 END AS RaiseAll,