I am having a hard time listing all the clients for which no invoice has been created in the last 6 weeks.Two tables are involved, client and invoice. My current query looks like this:
select MAX(invoice.created_date) 'Last Invoice Date', invoice.invoice_no 'Invoice No.', DATEDIFF(curdate(), max(invoice.created_date)) 'Days since last invoice created', client.name 'Client'
from invoice
left join
client on invoice.client_id = client.id
where
datediff (curdate(), (select MAX(invoice.created_date) from invoice left join client on invoice.client_id = client.id)) > 42
group by client.id;
But it returns an empty set. Any help would be appreciated