Subscribe
SELECT c.customer_id
FROM customer c LEFT OUTER JOIN invoice i
ON c.customer_id = i.customer_id
GROUP BY c.customer_id
HAVING MAX(i.invoice_date) IS NULL
OR MAX(i.invoice_date) < date_sub(curdate(), interval 2 month)br> >
select customer_id from customer
where not exists (select invoice_id from invoice
where invoice.customer_id = customer.customer_id
and invoice.invoice_date > DATE_SUB(CURDATE(), INTERVAL 2 MONTH))
You are not logged in, either login or create an account to post comments
posted by Nothing at 11:10 PM on September 3, 2007