title: Nested Case Statements in Hive
body: <p>Does anyone have an idea on why this code isn't working? </p>
  
  <pre><code>create table2 as
  select
      *,
      1 as count,
      case
          when a=1 then
              case 
                  when tx="A_L" then "L"
                  when tx="B_A" then "A"
                  when tx="C_E" then "E"
                  when tx in ("E_V","D_M","H_O","I_D") then "Other"
                  when tx="F_S" then "S"
                  when tx="G_L" then "L"
              end 
          when b=1 then 
              case
                  when tx="A_L" then "L"
                  when tx="B_A" then "A"
                  when tx="C_E" then "E"
              end
          else
              case
                  when tx="A_L" then "L"
                  when tx="B_A" then "A"
                  when tx="C_E" then "E"
                  when tx in ("D_M","E_V","F_S","H_O","I_D") then "Other"
                  when tx="G_L" then "L"
              end
      end as tx1
  from table1
  </code></pre>
  
  <p>Or is there a simpler way to do this? I'm writing this within a proc sql statement and pushing it to Hadoop (so it needs to be HiveQL compatible). </p>