What I am trying to accomplish is to find all the customers who have sales in the past but have not purchased from us in the last 2 years (SYSDATE - INTERVAL '2' YEAR)
Here is my code currently.
select invc.company
, invc.customer_id
, to_char(invc.invdate, 'mm/dd/yyyy') as date
, invc.name
, invc.address1
, invc.address2
, invc.city
, invc.state
, invc.zip_code
, invc.country
, invc.region_code
, invc.site
, sum(invc.sales) as SlsAmnt
from ifsinfo.hb_invoicing_all invc
where **THIS IS THE PART IM STUCK AT**
group by invc.company
, invc.customer_id
, invc.creation_date
, invc.name
, invc.address1
, invc.address2
, invc.city
, invc.state
, invc.zip_code
, invc.country
, invc.region_code
, invc.site
I am basically looking for a query that will return a list of customers who haven't purchased from us in 2 years or more.
SUM(SALES) = 0
within last 2 years+