7 Replies Latest reply: Apr 23, 2012 7:29 AM by cc cc RSS

    Nested SELECT/LOAD

      Hi,

       

      I have the following situation:

       

      An SQL table PROJECT which contains the following columns:

      IDUserName1UserName2UserName3
      1johnpaulsean
      2pierrepauljacques
      3johnsimonsean

       

      An Excel file TEAM which contains the following columns:

      UserNameUserTeam
      johnTeam1
      paulTeam2
      seanTeam3
      pierreTeam1
      jacquesTeam4
      simonTeam5

      The result table that should look like this:

      IDUserName1UserTeam1UserName2UserTeam2UserName3UserTeam3
      1johnTeam1paulTeam2seanTeam3
      2pierreTeam2paulTeam2jacquesTeam4
      3johnTeam1simonTeam5seanTeam3

       

       

      With two SQL tables, I would do something like:

       

      SELECT

      UserName1,

      UserTeam1,

      UserName2,

      UserTeam2,

      UserName3,

      UserTeam3

      FROM PROJECT

      LEFT OUTER JOIN(

      SELECT UserTeam1

      FROM TEAM) ON UserName1 = UserName

      LEFT OUTER JOIN(

      SELECT UserTeam2

      FROM TEAM) ON UserName2 = UserName

      LEFT OUTER JOIN(

      SELECT UserTeam3

      FROM TEAM) ON UserName3 = UserName

       

      Is it possible to do the same but instead of nested SELECT, data would be loaded from the Excel file?