title: How to achieve below code using Oracle PL/SQL
body: <p>How I can achieve below,
  I have to check last 30 days from the latest statement date w.r. to account using following formula</p>
  
  <pre><code>if ((sum of credits for 30 days from the latest statement date w.r. to account/
  sum debits for 30 days from the latest statement date w.r. to account)
  -sum debits for 30 days from the latest statement date w.r. to account)&gt;0 then YES else NO
  </code></pre>
  
  <p>below are the two columns from two different tables based on which i need to derived formula for each account. And accounts present in both tables A and B.</p>
  
  <pre><code>STATEMENT_DATE_LATEST; --from TableA
  LATEST_BAL_IN_USD; -- from TableB
  </code></pre>
  
  <p>Note: "/" is Divided by and "-" is Minus sign in above statement</p>