SELECT booking_id, agent_id from bookings
where booking_id in (
select receipts.booking_id from receipts join bookings where receipts.date <= DATE_ADD(bookings.date, INTERVAL 15 DAY) GROUP by receipts.booking_id having sum(receipts.net_amt) >= '50000'
@yadhul To make this work with Eloquent methods, you will have to use joins. Sometimes, if performance is an issue, it's fine to use queries like above.