title: Multiple column reference with a parent code
body: <p>I'm wondering how I could reference the three columns from <code>TBL_ITEM</code> to get <code>SUM(QTY) FROM TBL_INVTY</code>.</p>
  
  <p>TBL_ITEM</p>
  
  <pre><code>+------+-------------+----------+
  | CODE | PARENT_CODE | OLD_CODE |
  +------+-------------+----------+
  |    2 |        NULL |       20 |
  |   2A |           2 |     NULL |
  |   2B |           2 |     NULL | 
  |    3 |        NULL |     NULL |
  |    4 |        NULL |     NULL |
  |   20 |        NULL |     NULL |
  +------+-------------+----------+
  </code></pre>
  
  <p>TBL_INVTY</p>
  
  <pre><code>+------+-----+
  | CODE | QTY |
  +------+-----+
  |    2 |   2 |
  |   2A |   4 |
  |   2B |   1 |
  |    3 |   3 |
  |    4 |   5 |
  |   20 |   2 |
  +------+-----+
  </code></pre>
  
  <p>And, arrive on this:</p>
  
  <pre><code>+------+-----+
  | CODE | QTY |
  +------+-----+
  |    2 |   9 |
  |    3 |   3 |
  |    4 |   5 |
  +------+-----+
  </code></pre>
  
  <p>The first row on the last table <code>WHERE CODE=2</code> has a <code>QTY</code> of 9 because I took the <code>SUM(QTY) from TBL_INVTY WHERE CODE IN (20, 2A, 2B, 2)</code> with respect to the references made in <code>TBL_ITEM</code>.</p>