2 Replies Latest reply: Jun 2, 2011 9:13 PM by andrewcakedeals RSS

    Nested "Select" on a table during a Load

      Hi All,

       

      I have a question on loading a table. I want one of the columns to be the result of another nested Load. I know how to do this in SQL, but I'm not sure what the equivalent is in the QV script.

       

      For example:

       

      If I have tableA and tableB, the SQL may look like:

       

      SELECT tableA.field1, tableA.field2, (SELECT tableB.field1 FROM tableB WHERE tableB.field2 = '1')

      FROM table A

       

      What's a good way to do it in QV's syntax, assuming tableB is already loaded as a Resident? Is a nested Load even possible?

       

      Thanks in advance!

        • Nested "Select" on a table during a Load
          Chris Cammers

          The example that you've given is basically a left join between table a and b (except you don't have any correlating conditions between table A and B) Your options are pretty simple load records from Table A and then Join the rows from table b.

           

          something like this...

          TableC:

          Load

          Field1,

          Field2

          From TableA

           

          Left Join(TableC)

          Load

          Field1 as Field3

          from TableB

          Where Field2 = '1'

           

          without a mathcing field between the two queries you will end up with a cartesian product so if there is a matching field or "join conditoin" you should use renaming so the names match and Qlikview will automatically join based on the matching fields.