4 Replies Latest reply: May 25, 2012 5:44 AM by mario marino RSS

    two or more table (create from left joins) union script howto ?

      Hi,

       

      i'm tring to do an union with two or "n" tables created from a join instructions but i didn't create the correct scripting,

      I need to do a data union tab_A+Tab_B without creating syntetic keys

       

      Any suggenstions ?

       

      Thanks

       

      
      tab_A:
      SQL SELECT DTREG,
          NUMCON+'-'+cast(PRGCONTIA AS CHAR(6)) AS KUTE,
          TIPCON,
          NUMSVO,
          IDENTI1
      FROM winsmartptia.dbo.C01FCSVUOT WHERE DTREG>='01/01/2011';
      
      
      left join
      SQL SELECT NUMCON+'-'+cast(CPROWNUM AS CHAR(6)) AS KUTE,
          CATEG,
          ANNORID
      FROM winsmartptia.dbo."C01M_DTTIA" WHERE ANNORID>=2011;
      
      
      left join
      SQL SELECT TIPCON,
          DESCON,
          CONTE,
          TIPMAT
      FROM winsmartptia.dbo.C01FCTIPCOT;
      
      
      left join
      SQL SELECT CATEG,
          DOMEST
      FROM winsmartptia.dbo.C01TIATAR;
      
      
      
      
      tab_B:
      SQL SELECT DTREG,
          NUMCON+'-'+cast(PRGCONTIA AS CHAR(6)) AS KUTE,
          TIPCON,
          NUMSVO,
          IDENTI1
      FROM winsmartptia.dbo.C02FCSVUOT WHERE DTREG>='01/01/2011';
      
      
      left join
      SQL SELECT NUMCON+'-'+cast(CPROWNUM AS CHAR(6)) AS KUTE,
          CATEG,
          ANNORID
      FROM winsmartptia.dbo."C02M_DTTIA" WHERE ANNORID>=2011;
      
      
      left join
      SQL SELECT TIPCON,
          DESCON,
          CONTE,
          TIPMAT
      FROM winsmartptia.dbo.C02FCTIPCOT;
      
      
      left join
      SQL SELECT CATEG,
          DOMEST
      FROM winsmartptia.dbo.C02TIATAR;