1 Reply Latest reply on Mar 15, 2016 8:44 AM by Mithun Shanmugam

    Tableau Desktop - Custom SQL

    Mithun Shanmugam

      Hi all,

       

      I have a simple SQL contains subquery which runs perfectly fine in Oracle. I'm finding hard time to replicate this on Tableau. Can someone help me on this?

       

      select  Table_1.col_1, table_1.col_2,

      case when table_1.col_3 = 'AA' and table_1.col_4=x.Current_year1 then 'Y'

           when table_1.col_3 = 'AA' and table_1.col_4=x.current_year1 and col_4 is null then 'Y'

        else col_3 end as Flag

      From Table_1 , (select value as Current_year1 from Table_2 where parameter = 'Current_year') x

        • 1. Re: Tableau Desktop - Custom SQL
          Jeff Strauss

          try wrapping the entire select inside of parenthesis.  Because when Tableau executes custom SQL, it wraps it in it's own select which I believe is something like this.  If you want to confirm, you can look in the desktop logs.

           

           

          select TableauSQL.* from

          (

          (select  Table_1.col_1, table_1.col_2,

          case when table_1.col_3 = 'AA' and table_1.col_4=x.Current_year1 then 'Y'

               when table_1.col_3 = 'AA' and table_1.col_4=x.current_year1 and col_4 is null then 'Y'

            else col_3 end as Flag

          From Table_1 , (select value as Current_year1 from Table_2 where parameter = 'Current_year') x)) TableauSQL