title: Conditional SQL Query on Multiple Rows
body: <p>I am trying to find out which customers have defaulted on their loans. I would like to query the dataset to find the <em>User_id</em> of customers who have not paid in the last 60 days, but and not sure how to implement this in SQL.</p>
  
  <pre><code>User_id    Due_Date                Loan_Amount    Paid_Amount
  1          2012-04-04 16:14:12    500            40
  1          2012-05-04 16:14:12    500            40
  1          2012-06-04 16:14:12    500            0
  1          2012-07-04 16:14:12    500            0
  1          2012-08-04 16:14:12    500            0
  2          2012-02-15 03:30:55    2030           100
  2          2012-03-15 03:30:55    2030           100
  2          2012-04-15 03:30:55    2030           100
  3          2012-01-03 12:24:42    777            10
  3          2012-02-03 12:24:42    777            0
  3          2012-03-03 12:24:42    777            0
  3          2012-04-03 12:24:42    777            0
  </code></pre>
  
  <p>In pseudocode (shown in bold) would look something like this, but I can't seem to implement it in MySQL:</p>
  
  <p>SELECT User_id from TABLE_NAME WHERE Loan_Amount > 0 AND [<strong>the value Paid_Amount has been null for over 60 days</strong>]</p>
  
  <p>Desired Output:
  Users 1 and 3 in the above query would be returned because they have not paid for three consecutive periods.</p>
  
  <p>NOTE: Due_Date is a time stamp</p>
  
  <p>Any ideas would be very much appreciated!</p>