I am trying to get data that customer
who didnt have any new transaction with type deposit
within 30 days
Eg: customer MS00001 wont be query because it still have new record with deposit
within 30 day, the result should only show me MS00002 because it didnt have and type of deposit
within 30 days
meanwhile I have a customer table which have the customer details.
so how could I use 1 query to solve all of this
target output : transaction table + customer table who didnt have new record within 30 days
below is the query that I trying to get customer who didnt have any new record in transaction table.
SELECT t1.*
FROM transaction t1
LEFT JOIN (
SELECT customer FROM transaction
WHERE date <= DATE_SUB(SYSDATE(), INTERVAL 30 DAY)
) t2 ON t2customer = t1.customer
WHERE t1.date <= DATE_SUB(SYSDATE(), INTERVAL 30 DAY)
AND t1.type = 'deposit'
AND t2.customer IS NULL
ORDER BY trans_id DESC