Home > Net >  AWS Redshift SQL equivalent of Tableau
AWS Redshift SQL equivalent of Tableau

Time:10-07

I have this code in tableau which I need to convert to Redshift SQL

(
zn(
 sum([Market_Price])
  )-
zn(
 sum(
   if ISNULL([Market_Price]) then null else [Initial_Price] end
    )
))/
zn(sum([Market_Price]))

I have tried but not getting the same results. Do we have isnull and zn equivalent in Redshift?

CodePudding user response:

You can replace zn(X) with nvl(X,0)

CodePudding user response:

Something like this should work

select (
  coalesce(sum("Market_Price"),0) -
  coalesce(sum(case when "Market_Price" is null then null else "Initial_Price" end ),0) 
        ) / sum("Market_Price")
from your_redshift_table
;
  • Related