3 Replies Latest reply on Mar 3, 2017 5:43 PM by Vandana Samtani

    case statement calculation

    Vandana Samtani

      Hi All,

       

      I am trying to get a count of users that signed up by payment method. Since I want to combine couple of payment method into one, i am planning to do this using case statement.

       

      For e.g.

      Case when Media source like '%smarttv%' then smarttv'

      when payment_method in (ABC,DEF) Then 'Bank of america'

      When payment method in (GHI) then 'Chase'

      When payment_method in (HIJ) the 'Wellsfargo'

      end as payment_method is null then 'None'

      Else payment source end

       

      Any suggestions will be helpful on how to get counts using case statement or if there any other approaches. Below is the sample data -

       

      Thanks,

      Vandana

       

      sample data

         

      UseridPayment Methodsign up dateMedia source
      1ABC2/1/2017facebook
      2DEF2/1/2017appl
      3ABC2/1/2017smartv
      4GHI2/1/2017facebook
      5HIJ2/1/2017appl
      6ABC2/2/2017smartv
      7DEF2/2/2017facebook
      8ABC2/2/2017appl
      9GHI2/2/2017smartv
      10HIJ2/2/2017facebook
      11KLM2/2/2017appl
      12NOP2/2/2017smartv
      12ABC2/3/2017facebook
      12DEF2/3/2017appl
      12ABC2/3/2017smartv
      12GHI2/3/2017facebook
      12HIJ2/3/2017appl