Case When Invalid Argument Types For IFF Function

Hi,

Puzzled by this error message:
"Invalid argument types for function 'IFF': (Float, VARCHAR(7), VARCHAR(13))

Mostly because I am using Case When statement, not IFF
Any ideas?
Thanks



cte_revenue_product_group
        (Order_Nbr
         , Revenue_Product_Group)
    as
    (
        select
            o.order_nbr
            ,case
                when (left(rp.revenue_product, 6) = 'Alpha' and ie.Check ) then 'Zeta'
                when left(rp.revenue_product, 6) = 'Alpha' then 'Upsilon'
                when left(rp.revenue_product, 7) - 'Kappa' then 'Kappa'
                when contains(o.revenue_code_2, 'Mu') then 'Omicron'
                when contains(o.revenue_code_2, 'Pi') then 'Rho'
                else 'Omega'
                end
                "Revenue Product Group"
        from
            cte_order o
        inner join
            cte_revenue_product rp
        on
            o.order_nbr = rp.order_nbr
        inner join
            cte_is_enterprise ie
        on
            o.order_nbr = ie.order_nbr
    )
    select *
    from cte_revenue_product_group

It seems as if one (or more) of the "tables" in your join must be a view that uses IIF (?).

when left(rp.revenue_product, 7) - 'Kappa' then 'Kappa'

when left(rp.revenue_product, 7) = 'Kappa' then 'Kappa'

1 Like

Thanks RogierPronk,

Darn typo's!!

Huh? Why does a 5-char string, 'Kappa', require left(..., 7)? Followed by 2 spaces I guess.