How can I get this query to return the results I need?
Posted on 2013-06-03
I need to be able to determine a current Customer who has placed an order within the past year.
The current customer is determined by a customer placing an order within the past 5 years as in the Current query below.
Select Cust_IdA, Order_date
Where Order_date >= DATEADD(Year,-5, GETDATE())
That a Cust_IdA list is created based on Order_dates within the 1 year of getdate(), which would be from 2012-06-3 to 2013-06-3, and that the Cust_IdA is in the Current Cust_IdA list which is 540 IDs.
Close to an example:
The Cust_IdA list above is based on
Order_date >= DATEADD(Year,-1, GETDATE())
Would something like this work?
Where Order_date >= DATEADD(Year,-5,CONVERT (date, GETDATE()))
AND Order_Date >= DATEADD(Year,-1,CONVERT (date, GETDATE()))