12 Replies Latest reply: Jun 2, 2017 8:02 AM by Jarrad Murray RSS

    Group by and Union in SQL load statement

    Jarrad Murray

      Hi All,

       

      Sorry if I am posting this in the wrong place.

       

      I am trying to load two sets of data using SQL into a Qlik dashboard and seem to be having some difficulties. 


      I have loaded the first data set using the following syntax


      Qlik Table 1:

      SQL

      Select

           ,Column 1

           ,Column 2

           ,Count(*) as 'Column 3

      from

           Table 1

      Group by

           ,Column 1

           ,Column 2

       

      UNION ALL

       

      Select

           ,Column 1

           ,Column 2

           ,Count(*) as 'Column 3

      from

           Table 2

      Group by

           ,Column 1

           ,Column 2

      ;


      This works fine and creates a table in Qlik as expected.  Performing the same action for the second table causes Qlik to just ignore the load statement and not action anything.  The statement I am using is exactly the same just creating table 2 and getting the source data from a different set of tables.

      I have run the query code independently in SQL and the query works fine.  Confusingly, I can get the table to create itself by removing the group by aspect and running the SQL separately i.e.

       

      Qlik Table 2:

      SQL

      Select

           ,Column 1

           ,Column 2

           ,1 as 'Column 3

      from

           Table 3

      ;

       

      Qlik Table 2:

      SQL

      Select

           ,Column 1

           ,Column 2

           ,1 as 'Column 3

      from

           Table 4

      ;


      Does anyone have any idea as to what might be going on here and how I can revert my SQL query back to a group and union as I am dealing with hundreds of thousands of rows of data and am going to make the Qlik application massive by the time I have finished.