I have an invoice table that includes invoice dates (Date_Effective) per Company_ID, and I'm trying to essentially find those customers that, at one point or another, had a gap in invoicing of 2 years or more (for example--Customer ABC started invoicing on 1/1/2019 - 6/30/2020 and then resumed invoicing on 8/2/2023).
In addition, I'd love to run the query via a WHERE clause that would only pull customers that had an invoice date in a particular date range (so, using the example above, if I ran WHERE INVOICE_DATE BETWEEN 8/1/2023 & 8/3/2023 it would return Customer ABC, but if the BETWEEN was 7/30/2023 AND 8/1/2023 that customer would not be returned).
The table itself is extremely basic--four columns (Company_ID, Date_effective, Invoice_Amount, and Invoice_ID). As you can imagine, there are certainly multiple invoices for the same company & invoice date (just date, not datetime).