Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT borrowers.cardnumber, borrowers.surname, borrowers.firstname, borrowers.address, borrowers.city, borrowers.zipcode,
- borrowers.email, borrowers.phone,
- borrowers.dateofbirth, borrowers.debarred, borrowers.categorycode,
- FORMAT(SUM(accountlines.amountoutstanding),2) AS Due,
- min(accountlines.date) as 'oldest date',
- max(accountlines.date) as 'newest date'
- FROM borrowers, accountlines
- WHERE
- borrowers.borrowernumber in (select distinct borrowernumber from statistics where datetime > DATE_SUB(CURDATE(),INTERVAL 60 DAY) and type = 'payment')
- and borrowers.borrowernumber = accountlines.borrowernumber
- GROUP BY borrowers.borrowernumber
- HAVING SUM(accountlines.amountoutstanding) >= 25.00
- ORDER BY borrowers.surname ASC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement