2 Replies Latest reply on Jun 6, 2018 6:58 AM by vidhya srinivasan

    Pivot a table and join with another table

    vidhya srinivasan

      Hi,

       

      I am using the below query in Custom SQL , trying to pivot a table and join with another table. My data source is Oracle and this query works in Oracle, but not in Tableau. It is not taking in the join condition and throws an error as invalid identifier. I have tried tweaking the query and it is not working so far. Any help is appreciated.

       

      Just to be clear, Key ID values of 8,9, 10 etc  and their corresponding Key_val_txt are currently present as rows . i want to convert them as columns in my new table.

       

       

      select * from(

      (select * from DB.Tablename1 a

      join

      DB.Tablename2 b

      on a.ENTRY_ID = b.ENTRY_ID

      and a.key_id in (8,9,10,23,24,25,26,27,28,29)

      where b.abc = '0072' and

      b.def = 4) m

      pivot (max(key_val_txt) for key_id in ( 8,9,10,23,24,25,26,27,28,29)))p