4 Replies Latest reply on Jan 13, 2017 1:08 PM by john.christopher

    Custom SQL Properties

    john.christopher

      Hi All,

       

      I need some clarification on how custom SQL works in tableau

       

      Custom SQL Embedded into Tableau SQL

                E.G.: Select Row 1 from

                                    {

                                              Select * from Table 1

                                    }a

                                        

      • Why is the whole table selected and then custom SQL applied to it
      • Suggestion if we have large real time data and it is a live connection

       

      Thanks,

      JC

        • 1. Re: Custom SQL Properties
          Chris McClellan

          In this example, is your custom SQL the "select * from Table 1" ?

          • 2. Re: Custom SQL Properties
            john.christopher

            HI Chris,

             

            Please find the updated and correct me if I am wrong.

             

            Select Col1 from Table1(normal query)

             

            How tableau send:

            Select

            Col1, Col2 ---Custom Query

            From

            [

            SELECT

            Col1,

            Col2,

            Col3,

            Col4,

            ....,

            ColN

            From Table1

              ] a  

             

            Regards,

            JC

            • 3. Re: Custom SQL Properties
              Chris McClellan

              OK, so I just checked this rather than guessing

               

              I used the Access database called "Sample - Coffee Chain" (you get that on one of the training courses)

               

              My custom SQL  (just aliasing the table so that it was easier to spot):

               

              select * from factTable A
              

               

              Then I :

              - started Performance Recorder

              - dragged [Area Code] on to the view

              - stopped Performance Recorder

              - checked the generated SQL and got this :

               

               

              SELECT [Custom SQL Query].[Area Code] AS [Area Code]
              FROM (
                select * from factTable A
              ) [Custom SQL Query]
              GROUP BY [Custom SQL Query].[Area Code]
              

               

              So that shows that the custom SQL is within the Tableau query.

               

              Maybe you're at the same point I was when I started using Tableau, being "I know how to write SQL, I'll just do it myself" BUT ... it's much better to not write SQL and let Tableau write the SQL and do the query the way it wants to do.  You do use Custom SQL when there's something in the database that Tableau just can't do/understand.

               

              I hope that helps

              1 of 1 people found this helpful
              • 4. Re: Custom SQL Properties
                john.christopher

                Hi Chris,

                 

                Thank You for the reply.It helped.

                 

                Regards,

                JC