UPDATE Temp1 a
SET TimeStamp1 = CASE(
WHEN (a.TimeStamp1 IN
(SELECT TimeStamp1
FROM a
WHERE a.DealName = 'Disha Rufous'
AND a.DealStep = 'Sent for Risk feedback')
- a.TimeStamp1 IN
(SELECT TimeStamp1
FROM a
WHERE a.DealName = 'Disha Rufous'
AND a.DealStep = 'De-dupe confirmation received')
IS NOT NULL THEN '0' ELSE TimeStamp1 END)
WHERE Temp1.DealName = 'dede'
AND Temp1.StepName = 'Risk feedback addressed'
错误表示THEN
函数中的CASE
。
答案 0 :(得分:0)
您的CASE
是:
CASE
WHEN a IN (X) - a IN (Y) IS NOT NULL
THEN...
ELSE ...
END
我想您现在可以看到为什么它不会工作,您的WHEN
条款无效。 a IN (X)
返回true
或false
,从中减去另一个true/false
值然后查看它是否为空是没有意义的。
我猜你想要:
UPDATE Temp1 a SET TimeStamp1 = CASE
WHEN a.TimeStamp1 IN(SELECT TimeStamp1 FROM Temp1 WHERE DealName = 'Disha Rufous' AND DealStep = 'Sent for Risk feedback')
AND a.TimeStamp1 IN(SELECT TimeStamp1 FROM Temp1 WHERE DealName = 'Disha Rufous' AND DealStep = 'De-dupe confirmation received')
THEN '0'
ELSE TimeStamp1
END
WHERE DealName = 'dede' AND StepName = 'Risk feedback addressed'
根据您的要求,您可能需要在AND
子句中将OR
更改为WHEN
。