Reputation: 1624
Trying to do a case statement with 2 values. I tried following SQL Case with 2 conditions example but unable to get it.
Logic trying to do:
where stack
is in nodeName
and overflow
is in scenarioName
, then replace nodeName
value Stack
with Usethisvalue
, within the nodeName
column.
My query:
SELECT endOfDay as businessDate,
(CASE nodeName,
WHEN nodeName = 'Stack' AND scenarioName = 'Overflow' THEN Usethisvalue
END) as nodeName,
scenarioName, Value
FROM CONTRIBUTION
Can anyone help with this?
Upvotes: 0
Views: 49
Reputation: 31991
try like below
SELECT endOfDay as businessDate,
CASE WHEN nodeName = 'Stack' AND scenarioName = 'Overflow' THEN 'Usethisvalue'
else nodeName END as nodeName,
scenarioName, Value
FROM CONTRIBUTION
Upvotes: 3
Reputation: 212
SELECT
endOfDay as businessDate, nodeName, WHEN nodeName = 'Stack' AND scenarioName = 'Overflow' THEN Usethisvalue ELSE nodeName END as nodeName, scenarioName, Value FROM CONTRIBUTION
Upvotes: 0