title: How to write subquery inside the OUTER JOIN Statement
body: <p>I want to join two table CUSTMR and DEPRMNT.</p>
  
  <p>My needed is: LEFT OUTER JOIN OF two or more Tables with subquery inside the LEFT OUTER JOIN as shown below:</p>
  
  <p>Table: CUSTMR , DEPRMNT</p>
  
  <p>Query as:</p>
  
  <pre><code>SELECT
      cs.CUSID
      ,dp.DEPID
  FROM
      CUSTMR cs
          LEFT OUTER JOIN (
              SELECT
                      dp.DEPID
                      ,dp.DEPNAME
                  FROM
                      DEPRMNT dp
                  WHERE
                      dp.DEPADDRESS = 'TOKYO'
          )
              ON (
                  dp.DEPID = cs.CUSID
                  AND cs.CUSTNAME = dp.DEPNAME
              )
  WHERE
      cs.CUSID != ''
  </code></pre>
  
  <p>Here the subquery is:</p>
  
  <pre><code>SELECT
      dp.DEPID, dp.DEPNAME
  FROM
      DEPRMNT dp
  WHERE
      dp.DEPADDRESS = 'TOKYO'
  </code></pre>
  
  <p>Is it possible to write such subquery inside LEFT OUTER JOIN?</p>
  
  <p>I am getting an error when running this query on my DB2 database.</p>