I have a transaction table which contains purchase history of all the customers. I want to find out the number of customers who have have purchased within a week(7 days) of their 1st purchase anniversary(Using Min(Bill_Date))
Customer_Id Bill_Date
1 2020-01-23
1 2021-01-28
2 2020-09-01
2 2021-09-07
3 2020-03-01
So the expected output:
The No of customers who have purchased with a week of their 1st purchase anniversary is : 3
I am stuck after this step
with CTE As
(Select customer_id,Bill_Date from
(Select Customer_id,Bill_Date,Dense_Rank() over(partition by Customer_id order by Bill_Date)r1 from CDM_Bill_Details)t1
where t1.r1=1
group by customer_id)