5 Replies Latest reply: Jul 14, 2014 3:07 AM by Sasi Vardhan KV RSS

    Merging to SQL Tables (union way, vertically)

      Hi.

       

      my script looks like this:

       

      Table_A:

       

      select ... from ... where ... ;

       

      Table_B:

       

      select ... from ... where ... ;

       

      I want to merge these tables into Table_C?

       

      Table_C:

      [What's the script for it?]

       

      Thank YOU.

        • Re: Merging to SQL Tables (union way, vertically)

          Hi Gil

           

          Qlikview is very different from SQL in that the script is more step-wise.

           

          The cleanest way to achieve a merge of table A and B would be to load table A, then merge B into it as the next step using the "concatenate" statement. This would be the equivalent of a SQL select * from A union select * from B.

           

          TableA: Load * from TableA;

           

          concatenate(TableA) Load * from TableB;

           

          Both tableA and table B are in table A.

           

          Qlikview will automatically pick up fieldnames that are the same and put the values in the same column. Where column B has different filednames, then the rows in (original) table A will be null for these new fields.

           

          Erica

          • Re: Merging to SQL Tables (union way, vertically)
            Massimo Grossi



            Table_C:

            //Table_A:

            sql select ... from ... where ... ;

             

            concatenate (Table_C)

            //Table_B:

            sql select ... from ... where ... ;

            • Re: Merging to SQL Tables (union way, vertically)
              jagan mohan rao appala

              Hi,

               

              Try like this

               

              Table_C:

              select ... from ... where ... ;

               

              Concatenate(Table_C)

              select ... from ... where ... ;

               

              Regards,

              Jagan.

              • Re: Merging to SQL Tables (union way, vertically)
                Satyadev Jaiswal

                Hi,

                If the column names are identical in both the tables, you don't have to forcefully use "concatenate" to merge them together. QlikView will automatically merge them by writing below script and store them in table "Table_A"

                 

                Table_A:

                select ... from ... where ... ;

                 

                Table_B:

                select ... from ... where ... ;

                 

                If the names are not identical than using "concatenate" would be best option. See below,

                 

                Table_C:

                select ... from ... where ... ;

                Concatenate (Table_C)

                select ... from ... where ... ;

                • Re: Merging to SQL Tables (union way, vertically)
                  Sasi Vardhan KV

                  Table_A:

                   

                  Load ... from ... where ... ;

                   

                  left join(Table_A)

                  //Table_B:

                   

                  Load ... from ... where ... ;

                   

                  Both table_A and table_B will be in to one single table based on the one field join.

                   

                  If you want to merge these tables into Table_C?

                   

                  Table_C:

                   

                  Load *,

                  resident Table_A;

                   

                  Drop table Table_A;

                   

                  it will create one seperate table and will drop table_A and table_B