Link to home
Start Free TrialLog in
Avatar of patd1
patd1Flag for United States of America

asked on

Flag records based on service date

Please see attached excel file for sample data.
I want to mark records from the same customer as Index / ReIndex  (in the service_type column) based on the following rule:

Flag all records with svc_order =1 as 'Index' in Service_type column.

If customer_id is same
and svc_order>1
and DateDiff in days (svc_start_date for previous record where svc_order = svc_order-1, same customer_id) <=30

Then Flag it as Re-Index.

Attached sample data in excel file.
service_Type column will be initially null and updated as mentioned in the above logic.

How can I accomplish this using sql?
Index-ReIndex.xls
ASKER CERTIFIED SOLUTION
Avatar of Brian Crowe
Brian Crowe
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of patd1

ASKER

Awesome. Thank you.