title: How to LEFT JOIN in DB2 iseries with first row?
body: <p>I have need a query that JOIN a TABLE with A first row of other table value based:</p>
  
  <pre><code> SELECT * FROM TABLEA A LEFT JOIN
      (SELECT * from TABLEB
         WHERE FIELD1 &lt;&gt; '3' and FIELD2 = 'D' AND A.CODE=CODE
        FETCH FIRST 1 ROW ONLY
       ) B
   on a.FIELDA = b.FIELDA
   and A.FIELDB = B.FIELDB
  </code></pre>
  
  <p>but DB2 return ERROR because can't use <strong>A.CODE</strong></p>
  
  <p>How can solve this?   </p>