3 Replies Latest reply: Jan 11, 2010 9:29 AM by LukasIckerott RSS

    Load SQL result into variable

      Hi,

      Is it possible to load a single field SQL result into a Qlikview variable and use this variable in another SQL load.
      e.g.
      variable = Select foo from table:
      Select baa from table where baa < $(variable)

      If it's possible, please tell me the right syntax.

      thx in advance

      Tom (Newbee)

       

       

        • Load SQL result into variable

          Hi, based in your example the script must be something like

           


          tmp:
          Select foo from table;

          let variable = peek('foo',0,'tmp');
          drop table tmp;

          DATA:
          Select baa from table where baa < $(variable);


          rgds

            • Load SQL result into variable

              Hector, thx

              for some reason I don't understand, the function peek doesn't work. Maybe my example describes not my real need. I need a limitation of selected rows by a value of another table.
              But I got a result with function Fieldvalue.

              So the Syntax is

              Select foo from table1;
              let variable = FiledValue(foo,1);

              Select baa from table2 LIMIT $(variable);

               

                • Load SQL result into variable

                  Hi, here's an example how I use peek for a similar task:

                   

                   

                  PARTS_date:

                   

                  First 1
                  LOAD date#(left(@1,10),'MM-DD-YYYY') as UpdateDate
                  FROM [$(File)] (biff, no labels, table is [Sheet1$])

                  LET

                  vCurrFileDate = num(date(peek('UpdateDate',0,'PARTS_date')));

                   

                  vCurrFileDate = num(date(peek('UpdateDate',0,'PARTS_date')));

                   

                  vCurrFileDate = num(date(peek('UpdateDate',0,'PARTS_date')));