title: Left join with "select"
body: <p>Good day,</p>
  
  <p>Could someone please kindly explain to me what the below syntax is doing? I understand everything before it which is to join a table with this but in this case it's not a table that it's joining to, it looks like a selection and I was really confused about what it's trying to select.</p>
  
  <pre><code>LEFT OUTER JOIN (SELECT PARTRACKINFO.INVLOGID AS INVLOGID, GROUP_CONCAT(PARTRACKINFO.TRACKVALUE) AS TRACKVALUE
      FROM (SELECT TIINVENTORYLOG.INVENTORYLOGID AS INVLOGID, CONCAT(PARTTRACKING.ABBR, ': ',
              GROUP_CONCAT((CASE
  
                  WHEN PARTTRACKING.TYPEID = 20 THEN SUBSTRING(TIINVENTORYLOG.INFODATE FROM 1 FOR 11)
                  WHEN PARTTRACKING.TYPEID = 30 THEN SUBSTRING(TIINVENTORYLOG.INFODATE FROM 1 FOR 11)
                  WHEN PARTTRACKING.TYPEID = 40 THEN TIINVENTORYLOGSN.SERIALNUM
                  WHEN PARTTRACKING.TYPEID = 50 THEN CAST(TIINVENTORYLOG.INFODOUBLE AS DECIMAL(18,2))
                  WHEN PARTTRACKING.TYPEID = 60 THEN CAST(TIINVENTORYLOG.INFODOUBLE AS DECIMAL(18,5))
                  WHEN PARTTRACKING.TYPEID = 70 THEN TIINVENTORYLOG.INFOINTEGER
                  WHEN PARTTRACKING.TYPEID = 80 THEN TIINVENTORYLOG.INFOINTEGER
                  ELSE TIINVENTORYLOG.INFO
              END ))) AS TRACKVALUE
          FROM TIINVENTORYLOG
              INNER JOIN PARTTRACKING ON (TIINVENTORYLOG.PARTTRACKINGID = PARTTRACKING.ID)
              LEFT OUTER JOIN TIINVENTORYLOGSN ON (TIINVENTORYLOG.ID = TIINVENTORYLOGSN.TIINVENTORYLOGID)
              GROUP BY TIINVENTORYLOG.INVENTORYLOGID, PARTTRACKING.ABBR, PARTTRACKING.SORTORDER
          ORDER BY PARTTRACKING.SORTORDER) AS PARTRACKINFO
      GROUP BY PARTRACKINFO.INVLOGID) TRACKINFO ON (INVENTORYLOG.ID = TRACKINFO.INVLOGID)
  </code></pre>
  
  <p>Thanks</p>