Advertisement
Guest User

Untitled

a guest
Sep 8th, 2011
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. SELECT borrowers.cardnumber, borrowers.surname, borrowers.firstname, borrowers.address, borrowers.city, borrowers.zipcode,
  2. borrowers.email, borrowers.phone,
  3. borrowers.dateofbirth, borrowers.debarred, borrowers.categorycode,
  4. FORMAT(SUM(accountlines.amountoutstanding),2) AS Due,
  5. min(accountlines.date) as 'oldest date',
  6. max(accountlines.date) as 'newest date'
  7. FROM borrowers, accountlines
  8. WHERE
  9. borrowers.borrowernumber in (select distinct borrowernumber from statistics where datetime > DATE_SUB(CURDATE(),INTERVAL 60 DAY) and type = 'payment')
  10. and borrowers.borrowernumber = accountlines.borrowernumber
  11. GROUP BY borrowers.borrowernumber
  12. HAVING SUM(accountlines.amountoutstanding) >= 25.00
  13. ORDER BY borrowers.surname ASC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement