1 Reply Latest reply on Jun 13, 2016 9:26 AM by Derrick Austin

    How to use 'sub query' in sql in tableau

    Ram Atmakuri

      Hi All,

       

      Would like to seek help how to use a sql subquery in tableau? To be more precise, here is how my data looks like and I am currently getting the output that I need using a subquery in sql but not sure how to put this in tableau

       

      Projects Table

       

      Project classes (Not all projects have 'Final Destination' in the class_category and hence using sub query)

      query I am using in sql

       

      SELECT

      PPA.SEGMENT1 PROJ_NUM,

      SFD FINAL_DEST

      FROM

      pgp_ing_gpsorp77_foxtrot.pa_projects_all PPA left join

      (SELECT

      SPPA.SEGMENT1 SPN,

      SPPC.CLASS_CODE SFD

      FROM

      pgp_ing_gpsorp77_foxtrot.pa_projects_all SPPA,

      pgp_ing_gpsorp77_foxtrot.pa_project_CLASSES SPPC

      WHERE

      SPPC.PROJECT_ID = SPPA.PROJECT_ID

      AND SPPC.CLASS_CATEGORY = 'FINAL DESTINATION') as derivedtable

      on

      PPA.SEGMENT1  = SPN

      where

      PPA.SEGMENT1 IN ('7203010','7265383','7201535','7203048')

       

      output I am getting