Reputation: 2727
I have sql server script, that I need to convert to Redshift
Here is part of code that I have problem with
IIF(smf.channelid IS NULL, 0, 1) AS IsFeatureKey,
IIF(codeLabel.CslId > 0, 1, 0) AS IsCslCode,
IIF(codeLabel.LearnId > 0, 1, 0) AS IsLearnCode,
IIF(codeLabel.PMId > 0, 1, 0) AS IsPMCode,
IIF(codeLabel.UpSell > 0, 1, 0) AS IsUpSell
How I can convert it to Redshift correctly?
Upvotes: 1
Views: 3953
Reputation: 272376
IIF
is just syntactic sugar for CASE
expression (this behavior is mentioned in the documentation). Your code is identical to:
CASE WHEN smf.channelid IS NULL THEN 0 ELSE 1 END AS IsFeatureKey,
CASE WHEN codeLabel.CslId > 0 THEN 1 ELSE 0 END AS IsCslCode,
CASE WHEN codeLabel.LearnId > 0 THEN 1 ELSE 0 END AS IsLearnCode,
CASE WHEN codeLabel.PMId > 0 THEN 1 ELSE 0 END AS IsPMCode,
CASE WHEN codeLabel.UpSell > 0 THEN 1 ELSE 0 END AS IsUpSell
Upvotes: 6