1 Reply Latest reply on Jun 20, 2012 6:09 PM by Robert Morton

    Multiple custom sql

      I want to execute two sql queries and use the output data to perform some tasks on them. Can someone help me understand if its possible to run multiple custom queries in Tableau (using Teradata). If possible please share a sample

       

      Thanks

        • 1. Re: Multiple custom sql
          Robert Morton

          Hi Harsh,

           

          You will probably need to use the result of these queries to populate a temporary table, and use that temporary table in your Tableau connection. Since Tableau typically tries to hide temporary tables in the connection dialog, you will have to specify its name explicitly. Additionally note that for Teradata the temporary table will reside in the database that matches your user name.

           

          In the example below, consider a Teradata system with a user named 'test' and a database named TestV1. We may wish to perform some operations using data from TestV1, and we can stage these operations into a temporary table. I've arbitrarily named the temporary table "Initial SQL Test", but you can use any name you like. This will be the name of the table you type into the Tableau connection dialog.

           


          CREATE MULTISET VOLATILE TABLE "Initial SQL Test" AS (
          SELECT *
          FROM TestV1.Calcs
          ) WITH DATA
            ON COMMIT PRESERVE ROWS;

           

          INSERT INTO "Initial SQL Test"
          SELECT * FROM TestV1.Calcs;

          Start by opening the Tableau connection dialog and specifying your database connection information. Then click [Advanced...] to bring up the following dialog, where you can enter your initial SQL statements. Tableau will execute these statements immediately upon connecting.

           

          teradata-advanced.png

           

          Click OK to save these changes. Now in the connection dialog you can specify the temporary table name contained within the database that matches your user name. In this example, that is "test"."Initial SQL Test".

          teradata-connect.png

           

          I hope this helps,

          Robert