patd1
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER