I love this site, and it's helped me tons but this is my first posted question. I searched and cannot find an answer to this specific question. Very new to SQL.
Let's say I have a table that breaks down each line in an invoice where
TableName
OrderNumber, OrderDate, Product, CustomerID
What I want is to find out what customerID have ordered the SAME product more than once where those SAME product orders occurred within 90 days of each other.
I successfully made a query where I found customers that ordered the same product more than once:
select customerid, product, count(distinct ordernumber) as "count of orders"
from TableName
where orderdate > '2017-01-01'
group by customerid, product
having count(ordernumber) > 1
I can't seem to think my way through the rest.