title: Balance Negative for 3 months
body: <p>I have 3 tables. Account. Trans and Balance.</p>
  
  <p>Let's say account has 2 accounts only. Account Number 1 and 2.</p>
  
  <p>Both of them have multiple transactions in Trans Table.</p>
  
  <p>Sum(Amount) in Trans table equals balance at any given time for each account.</p>
  
  <p>For Example: Account 1 and 2 both had $50. Account 1 did transactions for $100 and Account 2 did transactions for $35 only.</p>
  
  <p>Now, Account 1 has a balance of Negative $50. Let's say he deposited $20. Regardless, balance is still negative.</p>
  
  <p>I need a query which checks that balance is negative for consecutive 3 months or more from today's date. (so sysdate whenever I would run this). Although he had a deposit of $20, the balance is still negative.</p>
  
  <p>When I use transdate from trans table or lastupdate from balance table as a 3 month criteria, the above account DOES NOT get picked up. Although, it is negative but it sees a transaction. </p>
  
  <p>I was wondering how can I query where it would display account number and balance only if it is negative for consecutive 3 months or more regardless of when the transaction occur.</p>
  
  <p>Columns:</p>
  
  <pre><code> Account Table has AccountID
   Trans Table has AccountID, Amount, TransDate
   Balance Table has AccountID, Balance, LastUpdate 
  </code></pre>
  
  <p>Thanks</p>
  
  <hr>
  
  <p>Update</p>
  
  <pre><code>Trans Table
  Select * from trans where accountid = 1;
  
  Transdate  Merchant    Amount   AccountID
  10/1/16    Employer    50       1
  10/4/16    Walmart     -20      1
  10/7/16    Kroger      -50      1
  </code></pre>
  
  <p>Now, his account went negative -$20 on 10/7/2016.</p>
  
  <pre><code> Transdate  Merchant    Amount   AccountID
   12/01/16   Employer    10       1
  </code></pre>
  
  <p>His Account is still negative. If I run the query today (01/15/2017) or later, his account should get picked up because he still has negative balance for at least 90 days. </p>
  
  <pre><code>Balance Table
  </code></pre>
  
  <p>It keeps only 1 record per Account.
  As of today, it shows the following:</p>
  
  <pre><code>AccountID    Balance    LastUpdate
  1            -10        12/01/2016
  </code></pre>
  
  <p>LastUpdate is the same date as the last date of transaction in Trans Table for that Account.</p>
  
  <p>I am going crazy on how to find the accounts who have been negative for 90 days or more even if the last deposit came yesterday but the accounts are still negative. I have 50,000 accounts that I need to do this for....</p>