title: SQL Query calculation across tables
body: <p>I have 3 tables that are joined using the following query:</p>
  
  <pre><code>SELECT 
      b.[_PRESS_INST_NO]
      ,a.[X_PO_NO]
      ,a.[X_GOODS_CD]
      ,a.[X_QTY]
      ,c.RM_CD
      ,c.RM_QTY
  FROM 
      T1 a
      INNER JOIN T2 b ON a.X_PO_NO=b.X_PO_NO
      INNER JOIN T3 c ON b._PRESS_INST_NO=c.[_PRESS_INST_NO]
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/jzMI6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jzMI6.png" alt="enter image description here"></a></p>
  
  <p>My desired result is <code>RM_QTYPerUnit</code> that can be done by Excel formula:</p>
  
  <pre><code>RM_QTYPerUnit = X_QTY * RM_QTY / SUM(X_QTY)
  </code></pre>
  
  <p>Total RM_QTY of X_PO_NO: VG00181 is 2320, and RM_QTY for X_GOODS_CD : 332034960 is 1094.34 not 2320.</p>