3 Replies Latest reply: Jun 17, 2013 3:22 AM by Vishwaranjan Kumar RSS

    Use SQL table fields multiple times

      Hi,

       

      Im a novice use of Qlikview (personal edition - desktop)

       

      I have made a connection to my MSSQL server and database

      In my database I have a table called Persons

       

      ID - NAME - MASTER_ID

      1     A               0

      2     B               0

      3     C               1

      4     D               2

      5     E               3

       

      In my Qlickview project I a have made a selection list

      My problem is that I only want to see the rows where MASTER_ID = 0

       

      This is my importscript:

       

      Bedrijfsleiders:

      [CODE]

      SQL

      SELECT *

      FROM "DW_MTC".dbo.Personeel WHERE baas_id = 0;

       

      Uitvoerders:

      SQL

      SELECT *

      FROM "DW_MTC".dbo.Personeel WHERE baas_id != 0;

      [/CODE]

       

      Export of the importscript

       

      Connecting to DW_MTC

      Connected

      Bedrijfsleiders << Personeel 2 regels opgehaald

      Bedrijfsleiders << Personeel 7 regels opgehaald

      ........

       

      I have tried diffrent things but a can't find a solutions. When I start the importscript like below I only see "Bedrijfsleiders"

        • Re: Use SQL table fields multiple times
          Gysbert Wassenaar

          WHERE baas_id != 0 may not work. Usually it's written as l WHERE baas_id <> 0;

           

          Also, if you load exactly the same fields then the data ends up in the first table. If you don't want that you can specify the noconcatenate keyword:

           

          Uitvoerders:

          noconcatenate load ...etc

           

          But you'll get a massive syntethic key.

           

          You can rename the fields or use the qualify keyword:

           

          qualify *;

          Uitvoerders:

          load ...etc

           

          That's also not a good idea. The best plan is to load the Persons table as it is with both the bedrijfsleiders and uitvoerders. You can use the baas_id field in expressions to distinguish between them.

           

          There's also the possibility to create a hierarchy table using the hierarchy keyword. Look at this discussion for an example.



          • Re: Use SQL table fields multiple times
            Vishwaranjan Kumar

            If you only want to see the rows where MASTER_ID = 0 from Persons table, then simply try this code.

             

            Load *

            where  MASTER_ID = 0;

             

            SQL

            SELECT *

            FROM  Persons;